Ver código fonte

core: make it possible to retrieve TCP connection without updating connection liifetime

Peter Dunkley 13 anos atrás
pai
commit
74a32e90a9
1 arquivos alterados com 5 adições e 4 exclusões
  1. 5 4
      tcp_main.c

+ 5 - 4
tcp_main.c

@@ -1540,10 +1540,11 @@ struct tcp_connection* tcpconn_get(int id, struct ip_addr* ip, int port,
 	if (likely(c)){ 
 			atomic_inc(&c->refcnt);
 			/* update the timeout only if the connection is not handled
-			 * by a tcp reader (the tcp reader process uses c->timeout for 
-			 * its own internal timeout and c->timeout will be overwritten
-			 * anyway on return to tcp_main) */
-			if (likely(c->reader_pid==0))
+			 * by a tcp reader _and_the timeout is non-zero  (the tcp
+			 * reader process uses c->timeout for its own internal
+			 * timeout and c->timeout will be overwritten * anyway on
+			 * return to tcp_main) */
+			if (likely(c->reader_pid==0 && timeout != 0))
 				c->timeout=get_ticks_raw()+timeout;
 	}
 	TCPCONN_UNLOCK;