From 89a9787cf0f3b1e33bedd63ef0a8cfd99074ca72 Mon Sep 17 00:00:00 2001 From: teodor Date: Wed, 29 Sep 2004 17:34:30 +0000 Subject: [PATCH] add timeout to TC_ServerConnect --- connection.h | 2 +- tcp.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/connection.h b/connection.h index 2bc936d..7c0db10 100644 --- a/connection.h +++ b/connection.h @@ -79,7 +79,7 @@ TC_Connection *TC_fillConnection( TC_Connection *cs, char *name, u_int32_t port TC_Connection* TC_AcceptTcp(TC_Connection *cs); u_int32_t TC_ClientInitConnection(TC_Connection *cs, char *name, u_int32_t port); u_int32_t TC_ServerInitConnect( TC_Connection *cs ); -u_int32_t TC_ServerConnect( TC_Connection *cs ); +u_int32_t TC_ServerConnect( TC_Connection *cs, int timeout ); u_int32_t TC_Send( TC_Connection *cs ); u_int32_t TC_Read( TC_Connection *cs ); u_int32_t TC_Talk( TC_Connection *cs ); diff --git a/tcp.c b/tcp.c index 26afeaf..df10a46 100644 --- a/tcp.c +++ b/tcp.c @@ -208,12 +208,12 @@ TC_ServerInitConnect( TC_Connection *cs ) { } cs->state = CS_INPROCESS; - return TC_ServerConnect( cs ); + return TC_ServerConnect( cs, 0 ); } u_int32_t -TC_ServerConnect( TC_Connection *cs ) { +TC_ServerConnect( TC_Connection *cs, int timeout ) { struct pollfd pfd; int ret; @@ -223,7 +223,7 @@ TC_ServerConnect( TC_Connection *cs ) { pfd.fd = cs->fd; pfd.events = POLLOUT; pfd.revents = 0; - ret = poll( &pfd, 1, 0 ); + ret = poll( &pfd, 1, timeout ); if ( ret<0 ) { tlog( TL_CRIT, "TC_ServerConnect: poll: %s", strerror(errno)); @@ -426,7 +426,7 @@ TC_Talk( TC_Connection *cs ) { u_int32_t ret = TC_ServerInitConnect( cs ); while( ret == CS_INPROCESS ) { - ret = TC_ServerConnect(cs); + ret = TC_ServerConnect(cs, 100); } if ( ret != CS_CONNECTED ) -- 2.37.3