mirror of
				https://github.com/berlin-open-wireless-lab/DAWN.git
				synced 2025-03-09 15:40:12 +00:00 
			
		
		
		
	network: dump detail on ping pong received
This also fix a typo error on check_timeout on wrong list
Fixes: 47e98ef ("network: ping pong keepalive for tcp connections")
Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
			
			
This commit is contained in:
		
							parent
							
								
									bb362db2fa
								
							
						
					
					
						commit
						10fb04317b
					
				
					 1 changed files with 5 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -190,6 +190,7 @@ static void client_read_cb(struct ustream *s, int bytes) {
 | 
			
		|||
 | 
			
		||||
            /* received pong */
 | 
			
		||||
            if (cl->final_len == HEADER_SIZE + PONG_SIZE && memcmp(cl->str + HEADER_SIZE, PONG_STR, PONG_SIZE) == 0) {
 | 
			
		||||
                dawnlog_info("Server: received pong from %s:%u, now=%d\n", inet_ntoa(cl->sin.sin_addr), ntohs(cl->sin.sin_port), (int)time(0));
 | 
			
		||||
                goto process_done;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -288,6 +289,7 @@ static void client_ping_read_cb(struct ustream *s, int bytes) {
 | 
			
		|||
        char final_str[HEADER_SIZE + PONG_SIZE];
 | 
			
		||||
        uint32_t *msg_header = (uint32_t *)final_str;
 | 
			
		||||
 | 
			
		||||
        dawnlog_info("Client: received ping from %s:%u, now=%d\n", inet_ntoa(con->sock_addr.sin_addr), ntohs(con->sock_addr.sin_port), (int)time(0));
 | 
			
		||||
        con->time_alive = time(0);
 | 
			
		||||
 | 
			
		||||
        *msg_header = htonl(final_len);
 | 
			
		||||
| 
						 | 
				
			
			@ -504,7 +506,7 @@ void check_timeout(int timeout) {
 | 
			
		|||
        list_for_each_entry_safe(cl, tmp, &cli_list, list)
 | 
			
		||||
        {
 | 
			
		||||
            if (now - cl->time_alive > timeout || now - cl->time_alive < -timeout) {
 | 
			
		||||
                dawnlog_info("server: close client connection! timeout=%d\n", (int)(now - cl->time_alive));
 | 
			
		||||
                dawnlog_info("Client: close client connection! timeout=%d\n", (int)(now - cl->time_alive));
 | 
			
		||||
                client_close(&cl->s.stream);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -513,10 +515,10 @@ void check_timeout(int timeout) {
 | 
			
		|||
    do {
 | 
			
		||||
        struct network_con_s *con, *tmp;
 | 
			
		||||
        time_t now = time(0);
 | 
			
		||||
        list_for_each_entry_safe(con, tmp, &cli_list, list)
 | 
			
		||||
        list_for_each_entry_safe(con, tmp, &tcp_sock_list, list)
 | 
			
		||||
        {
 | 
			
		||||
            if (now - con->time_alive > timeout || now - con->time_alive < -timeout) {
 | 
			
		||||
                dawnlog_info("client: close client_to_server connection! timeout=%d\n", (int)(now - con->time_alive));
 | 
			
		||||
                dawnlog_info("Server: close client_to_server connection! timeout=%d\n", (int)(now - con->time_alive));
 | 
			
		||||
                ustream_free(&con->stream.stream);
 | 
			
		||||
                dawn_unregmem(&con->stream.stream);
 | 
			
		||||
                close(con->fd.fd);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue