Browse Source

tcp: tcp_blocking_connect timeout fix

- tcp_blocking_connect timeout might have elapsed sooner then
  configured due to a bug in the way it was checked in the code.
  (affects tcp only in the old non-async mode)


Author: Libor Chocholaty <[email protected]>
Committer: Andrei Pelinescu-Onciul <[email protected]>
Andrei Pelinescu-Onciul 16 năm trước cách đây
mục cha
commit
98d282a690
1 tập tin đã thay đổi với 3 bổ sung5 xóa
  1. 3 5
      tcp_main.c

+ 3 - 5
tcp_main.c

@@ -520,17 +520,15 @@ again:
 #endif
 	while(1){
 		elapsed=(get_ticks()-ticks)*TIMER_TICK;
-		if (elapsed<to)
-			to-=elapsed;
-		else 
+		if (elapsed>=to)
 			goto error_timeout;
 #if defined(HAVE_SELECT) && defined(BLOCKING_USE_SELECT)
 		sel_set=orig_set;
-		timeout.tv_sec=to;
+		timeout.tv_sec=to-elapsed;
 		timeout.tv_usec=0;
 		n=select(fd+1, 0, &sel_set, 0, &timeout);
 #else
-		n=poll(&pf, 1, to*1000);
+		n=poll(&pf, 1, (to-elapsed)*1000);
 #endif
 		if (n<0){
 			if (errno==EINTR) continue;