Jelajahi Sumber

修改可能引起多初始化的bug

zzj 6 tahun lalu
induk
melakukan
02a4b42a34
3 mengubah file dengan 6 tambahan dan 5 penghapusan
  1. 2 2
      main.cpp
  2. 1 1
      zloop.h
  3. 3 2
      znet.cpp

+ 2 - 2
main.cpp

@@ -109,9 +109,8 @@ struct Init_Setting
 void cleanup() 
 { 
     module_mgr::stop();
-
-	ev_loop_destroy(ev_default_loop());
 }
+
 void usage(char ** argv)
 {
 	std::string cmd(argv[1]);
@@ -134,6 +133,7 @@ void usage(char ** argv)
 
 
 }
+
 int main(int argc ,char * argv[])
 {
 	if(argc >1)

+ 1 - 1
zloop.h

@@ -31,8 +31,8 @@ struct zloop_base:ev::dynamic_loop
 	}
 
 	zloop_base()
+		:m_async(*this)
 	{
-		m_async.set(*this);
 		m_async.set<zloop_base,&zloop_base::on_async_0>(this);
 		m_async.start();
 	}

+ 3 - 2
znet.cpp

@@ -191,10 +191,11 @@ struct sock_client:fd_io,client_ex
 		:fd_io(ic,fd,EV_READ|EV_WRITE)
 		,m_ic(ic)
 		,m_name(name)
+		,m_recv_timer(ic)
 	{ 
 		m_max_package_size=max_package_size;
 
-		m_recv_timer.set(ic);
+//		m_recv_timer.set(ic);
 		m_recv_timer.set(recv_time_out,0);
 		m_recv_timer.set<sock_client,&sock_client::on_recv_timeout>(this);
 		m_recv_timer.start();
@@ -469,7 +470,7 @@ struct signal_w:ev::sig
 	signal_w(io_context&ic, int s)
 		:m_ic(ic)
 	{
-		this->set(m_ic);
+//		this->set(m_ic);
 		this->set(this);
 		this->set(s);
 		this->start();