[SR-Dev] git:ser_core_cvs: tcp: tcp_blocking_connect timeout fix
Andrei Pelinescu-Onciul
andrei at iptel.org
Thu Apr 16 13:25:05 CEST 2009
Module: sip-router
Branch: ser_core_cvs
Commit: 98d282a690331cb2f1bcd97f32d307f71290e752
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=98d282a690331cb2f1bcd97f32d307f71290e752
Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date: Fri Apr 10 10:26:01 2009 +0000
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 at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
---
tcp_main.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/tcp_main.c b/tcp_main.c
index 6f7271a..4f93154 100644
--- a/tcp_main.c
+++ b/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;
More information about the sr-dev
mailing list