浏览代码

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

Peter Dunkley 13 年之前
父节点
当前提交
74a32e90a9
共有 1 个文件被更改,包括 5 次插入4 次删除
  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)){ 
 	if (likely(c)){ 
 			atomic_inc(&c->refcnt);
 			atomic_inc(&c->refcnt);
 			/* update the timeout only if the connection is not handled
 			/* 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;
 				c->timeout=get_ticks_raw()+timeout;
 	}
 	}
 	TCPCONN_UNLOCK;
 	TCPCONN_UNLOCK;