Browse code

- fixed wrong expire time calculation (not correct when tick oveflow, an timeout == some value before the overflow). This should fix the connection lives forever bug reported by Alfred E. Heggestad <aeh@db.org>.

Andrei Pelinescu-Onciul authored on 20/02/2007 18:20:15
Showing 1 changed files
... ...
@@ -36,6 +36,7 @@
36 36
  * 2005-07-05  migrated to the new io_wait code (andrei)
37 37
  * 2006-02-03  use tsend_stream instead of send_all (andrei)
38 38
  * 2006-10-13  added STUN support - state machine for TCP (vlada)
39
+ * 2007-02-20  fixed timeout calc. bug (andrei)
39 40
  */
40 41
 
41 42
 #ifdef USE_TCP
... ...
@@ -799,7 +800,7 @@ skip:
799 799
 					}
800 800
 				}else{
801 801
 					/* timeout */
802
-					if (con->timeout<=ticks){
802
+					if ((s_ticks_t)(ticks-con->timeout)>=0){
803 803
 						/* expired, return to "tcp main" */
804 804
 						DBG("tcp_receive_loop: %p expired (%d, %d)\n",
805 805
 								con, con->timeout, ticks);
... ...
@@ -943,7 +944,7 @@ static inline void tcp_receive_timeout()
943 943
 			release_tcpconn(con, CONN_ERROR, tcpmain_sock);
944 944
 			continue;
945 945
 		}
946
-		if (con->timeout<=ticks){
946
+		if ((s_ticks_t)(ticks-con->timeout)>=0){
947 947
 			/* expired, return to "tcp main" */
948 948
 			DBG("tcp_receive_loop: %p expired (%d, %d)\n",
949 949
 					con, con->timeout, ticks);