Forráskód Böngészése

添加分站连接和断开时的日志

zzj 6 éve
szülő
commit
c7f714629c
1 módosított fájl, 9 hozzáadás és 4 törlés
  1. 9 4
      znet.cpp

+ 9 - 4
znet.cpp

@@ -94,7 +94,7 @@ public:
 
 	void on_message(std::shared_ptr<client> clt,const char*data,size_t len)
 	{
-		m_serv.on_message(clt,data,len);
+//		m_serv.on_message(clt,data,len);
 	}
 
 	void close_all()
@@ -191,6 +191,7 @@ struct sock_client:fd_io,client_ex
 	int   m_clen{0};
 	int   m_size{1<<16};
 	int   m_max_package_size{2048};
+	int   m_recv_time_out;
 
 	ev::timer  m_recv_timer;
 	ev::timer  m_sync_timer;
@@ -212,6 +213,7 @@ struct sock_client:fd_io,client_ex
 		,m_sync_timer(ic)
 	{ 
 		m_max_package_size=max_package_size;
+		m_recv_time_out=recv_time_out;
 
 //		m_recv_timer.set(ic);
 		m_recv_timer.set<sock_client,&sock_client::on_recv_timeout>(this);
@@ -319,6 +321,7 @@ struct sock_client:fd_io,client_ex
 	void on_recv_timeout()
 	{
 		m_ic.on_recv_timeout(shared_from_this());
+		log_info("socket %s recv timeout.",m_name.c_str());
 	}
 
 	std::string name()
@@ -380,6 +383,8 @@ struct sock_client:fd_io,client_ex
 //		m_send_timer.stop();
 		fd_io::stop();
 		m_ic.on_close(shared_from_this());
+
+		log_info("socket %s closed.",m_name.c_str());
 	}
 
 	size_t calc_length(uint8_t*b)const
@@ -411,8 +416,6 @@ struct sock_client:fd_io,client_ex
 					return -1;
 				}
 
-
-
 				if(m_clen<msg_len)
 					break;
 
@@ -521,7 +524,7 @@ struct sock_client:fd_io,client_ex
 			}
 
 //			log_info("use time %d ms.",c.count_us());
-			m_recv_timer.set(5);
+			m_recv_timer.start(m_recv_time_out);
 		}
 	}
 
@@ -571,6 +574,8 @@ struct sock_listen: fd_io
 
 		zio::setiobuf(fd,32<<10,32<<10);
 		m_ic.on_connect(std::make_shared<sock_client>(m_ic,name,fd,recv_time_out,max_package_size));
+
+		logn_info(1,"socket %s connected.",name);
 	}
 };