Browse code

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 <libor@iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei@iptel.org>

Andrei Pelinescu-Onciul authored on 10/04/2009 10:26:01
Showing 1 changed files
... ...
@@ -520,17 +520,15 @@ again:
520 520
 #endif
521 521
 	while(1){
522 522
 		elapsed=(get_ticks()-ticks)*TIMER_TICK;
523
-		if (elapsed<to)
524
-			to-=elapsed;
525
-		else 
523
+		if (elapsed>=to)
526 524
 			goto error_timeout;
527 525
 #if defined(HAVE_SELECT) && defined(BLOCKING_USE_SELECT)
528 526
 		sel_set=orig_set;
529
-		timeout.tv_sec=to;
527
+		timeout.tv_sec=to-elapsed;
530 528
 		timeout.tv_usec=0;
531 529
 		n=select(fd+1, 0, &sel_set, 0, &timeout);
532 530
 #else
533
-		n=poll(&pf, 1, to*1000);
531
+		n=poll(&pf, 1, (to-elapsed)*1000);
534 532
 #endif
535 533
 		if (n<0){
536 534
 			if (errno==EINTR) continue;