Bladeren bron

- 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 <[email protected]>.

Andrei Pelinescu-Onciul 18 jaren geleden
bovenliggende
commit
1eee4c4ddb
1 gewijzigde bestanden met toevoegingen van 3 en 2 verwijderingen
  1. 3 2
      tcp_read.c

+ 3 - 2
tcp_read.c

@@ -36,6 +36,7 @@
  * 2005-07-05  migrated to the new io_wait code (andrei)
  * 2006-02-03  use tsend_stream instead of send_all (andrei)
  * 2006-10-13  added STUN support - state machine for TCP (vlada)
+ * 2007-02-20  fixed timeout calc. bug (andrei)
  */
 
 #ifdef USE_TCP
@@ -799,7 +800,7 @@ skip:
 					}
 				}else{
 					/* timeout */
-					if (con->timeout<=ticks){
+					if ((s_ticks_t)(ticks-con->timeout)>=0){
 						/* expired, return to "tcp main" */
 						DBG("tcp_receive_loop: %p expired (%d, %d)\n",
 								con, con->timeout, ticks);
@@ -943,7 +944,7 @@ static inline void tcp_receive_timeout()
 			release_tcpconn(con, CONN_ERROR, tcpmain_sock);
 			continue;
 		}
-		if (con->timeout<=ticks){
+		if ((s_ticks_t)(ticks-con->timeout)>=0){
 			/* expired, return to "tcp main" */
 			DBG("tcp_receive_loop: %p expired (%d, %d)\n",
 					con, con->timeout, ticks);