2
0
Эх сурвалжийг харах

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 жил өмнө
parent
commit
98d282a690
1 өөрчлөгдсөн 3 нэмэгдсэн , 5 устгасан
  1. 3 5
      tcp_main.c

+ 3 - 5
tcp_main.c

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