Browse Source

improve heartbeat

wangyu- 8 years ago
parent
commit
43ae798e77
2 changed files with 12 additions and 2 deletions
  1. 11 1
      connection.cpp
  2. 1 1
      main.cpp

+ 11 - 1
connection.cpp

@@ -711,7 +711,17 @@ int parse_safer(conn_info_t &conn_info,const char * input,int input_len,char &ty
 		conn_info.oppsite_roller=roller;
 		conn_info.last_oppsite_roller_time=get_current_time();
 	}
-	conn_info.my_roller++;//increase on a successful recv
+	if(hb_mode==0)
+		conn_info.my_roller++;//increase on a successful recv
+	else if(hb_mode==1)
+	{
+		if(type=='h')
+			conn_info.my_roller++;
+	}
+	else
+	{
+		assert(0==1);
+	}
 
 
 	if(after_recv_raw0(conn_info.raw_info)!=0) return -1;

+ 1 - 1
main.cpp

@@ -439,7 +439,7 @@ int client_on_raw_recv(conn_info_t &conn_info) //called when raw fd received a p
 		}
 		if(data_len>=0&&type=='h')
 		{
-			mylog(log_debug,"[hb]heart beat received\n");
+			mylog(log_debug,"[hb]heart beat received,oppsite_roller=%d\n",int(conn_info.oppsite_roller));
 			conn_info.last_hb_recv_time=get_current_time();
 			return 0;
 		}