From: wessels <> Date: Sat, 28 Mar 1998 05:44:18 +0000 (+0000) Subject: Changed comm connect routines so that the timeout value and handler X-Git-Tag: SQUID_3_0_PRE1~3732 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=86cf9987fab345f8d197ce36ab9dc59f06f18a8b;p=thirdparty%2Fsquid.git Changed comm connect routines so that the timeout value and handler are CLEARED when connection succeeds. This means all the connect callback (CNCB) functions need to re-set the timeout handlers. --- diff --git a/src/asn.cc b/src/asn.cc index 59b90702d2..face8dd288 100644 --- a/src/asn.cc +++ b/src/asn.cc @@ -1,5 +1,5 @@ /* - * $Id: asn.cc,v 1.27 1998/03/17 02:42:25 wessels Exp $ + * $Id: asn.cc,v 1.28 1998/03/27 22:44:18 wessels Exp $ * * DEBUG: section 53 AS Number handling * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -83,6 +83,7 @@ typedef struct _rtentry rtentry; static int asnAddNet(char *, int); static void asnCacheStart(int as); static PF whoisClose; +static PF whoisTimeout; static CNCB whoisConnectDone; static PF whoisReadReply; static STCB asHandleReply; @@ -377,7 +378,16 @@ whoisConnectDone(int fd, int status, void *data) snprintf(buf, 128, "%s\r\n", strBuf(p->request->urlpath) + 1); debug(53, 3) ("whoisConnectDone: FD %d, '%s'\n", fd, strBuf(p->request->urlpath) + 1); comm_write(fd, xstrdup(buf), strlen(buf), NULL, p, xfree); - commSetSelect(fd, COMM_SELECT_READ, whoisReadReply, p, Config.Timeout.read); + commSetSelect(fd, COMM_SELECT_READ, whoisReadReply, p, 0); + commSetTimeout(fd, Config.Timeout.read, whoisTimeout, p); +} + +static void +whoisTimeout(int fd, void *data) +{ + whoisState *p = data; + debug(53, 1) ("whoisTimeout: %s\n", storeUrl(p->entry)); + whoisClose(fd, p); } static void diff --git a/src/ftp.cc b/src/ftp.cc index 9dff3b0aca..5b31a4fca7 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.211 1998/03/27 19:41:58 wessels Exp $ + * $Id: ftp.cc,v 1.212 1998/03/27 22:44:20 wessels Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -1013,7 +1013,8 @@ ftpConnectDone(int fd, int status, void *data) ftpState->data.buf = xmalloc(SQUID_TCP_SO_RCVBUF); ftpState->data.size = SQUID_TCP_SO_RCVBUF; ftpState->data.freefunc = xfree; - commSetSelect(fd, COMM_SELECT_READ, ftpReadControlReply, ftpState, Config.Timeout.read); + commSetSelect(fd, COMM_SELECT_READ, ftpReadControlReply, ftpState, 0); + commSetTimeout(fd, Config.Timeout.read, ftpTimeout, ftpState); } } diff --git a/src/gopher.cc b/src/gopher.cc index 3496fd4ae4..51c5ae5518 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -1,6 +1,6 @@ /* - * $Id: gopher.cc,v 1.123 1998/03/16 21:59:58 wessels Exp $ + * $Id: gopher.cc,v 1.124 1998/03/27 22:44:21 wessels Exp $ * * DEBUG: section 10 Gopher * AUTHOR: Harvest Derived @@ -926,6 +926,7 @@ gopherConnectDone(int fd, int status, void *data) comm_close(fd); } else { commSetSelect(fd, COMM_SELECT_WRITE, gopherSendRequest, gopherState, 0); + commSetTimeout(fd, Config.Timeout.read, gopherTimeout, gopherState); } } diff --git a/src/http.cc b/src/http.cc index 58341b4b03..b3d6fdbe47 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.257 1998/03/20 18:06:44 rousskov Exp $ + * $Id: http.cc,v 1.258 1998/03/27 22:44:22 wessels Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -948,6 +948,7 @@ httpConnectDone(int fd, int status, void *data) fd_note(fd, storeUrl(entry)); fd_table[fd].uses++; commSetSelect(fd, COMM_SELECT_WRITE, httpSendRequest, httpState, 0); + commSetTimeout(fd, Config.Timeout.read, httpTimeout, httpState); } } diff --git a/src/ident.cc b/src/ident.cc index a81b525b63..860689d955 100644 --- a/src/ident.cc +++ b/src/ident.cc @@ -1,6 +1,6 @@ /* - * $Id: ident.cc,v 1.38 1998/03/17 00:38:53 wessels Exp $ + * $Id: ident.cc,v 1.39 1998/03/27 22:44:23 wessels Exp $ * * DEBUG: section 30 Ident (RFC 931) * AUTHOR: Duane Wessels @@ -35,6 +35,7 @@ static PF identReadReply; static PF identClose; +static PF identTimeout; static CNCB identConnectDone; static void identCallback(ConnStateData * connState); @@ -45,6 +46,15 @@ identClose(int fdnotused, void *data) connState->ident.fd = -1; } +static void +identTimeout(int fd, void *data) +{ + ConnStateData *connState = data; + debug(30,3)("identTimeout: FD %d, %s\n", fd, + inet_ntoa(connState->peer.sin_addr)); + comm_close(fd); +} + /* start a TCP connection to the peer host on port 113 */ void identStart(int fd, ConnStateData * connState, IDCB * callback, void *data) @@ -90,6 +100,7 @@ identConnectDone(int fd, int status, void *data) ntohs(connState->me.sin_port)); comm_write(fd, xstrdup(reqbuf), strlen(reqbuf), NULL, connState, xfree); commSetSelect(fd, COMM_SELECT_READ, identReadReply, connState, 0); + commSetTimeout(fd, Config.Timeout.read, identTimeout, connState); } static void diff --git a/src/ssl.cc b/src/ssl.cc index 341358b013..213763c1c4 100644 --- a/src/ssl.cc +++ b/src/ssl.cc @@ -1,6 +1,6 @@ /* - * $Id: ssl.cc,v 1.75 1998/03/04 23:52:42 wessels Exp $ + * $Id: ssl.cc,v 1.76 1998/03/27 22:44:25 wessels Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -130,11 +130,8 @@ sslReadServer(int fd, void *data) commSetSelect(sslState->server.fd, COMM_SELECT_READ, sslReadServer, - sslState, 0); - commSetTimeout(sslState->server.fd, - Config.Timeout.read, - NULL, - NULL); + sslState, + Config.Timeout.read); } else { sslClose(sslState); } @@ -145,11 +142,11 @@ sslReadServer(int fd, void *data) sslState->server.offset = 0; sslState->server.len = len; /* extend server read timeout */ - commSetTimeout(sslState->server.fd, Config.Timeout.read, NULL, NULL); commSetSelect(sslState->client.fd, COMM_SELECT_WRITE, sslWriteClient, - sslState, 0); + sslState, + Config.Timeout.read); } } @@ -225,11 +222,8 @@ sslWriteServer(int fd, void *data) commSetSelect(sslState->client.fd, COMM_SELECT_READ, sslReadClient, - sslState, 0); - commSetTimeout(sslState->server.fd, - Config.Timeout.read, - NULL, - NULL); + sslState, + Config.Timeout.read); } else { /* still have more to write */ commSetSelect(sslState->server.fd, @@ -277,11 +271,8 @@ sslWriteClient(int fd, void *data) commSetSelect(sslState->server.fd, COMM_SELECT_READ, sslReadServer, - sslState, 0); - commSetTimeout(sslState->server.fd, - Config.Timeout.read, - NULL, - NULL); + sslState, + Config.Timeout.read); } else { /* still have more to write */ commSetSelect(sslState->client.fd, @@ -307,7 +298,6 @@ sslConnected(int fd, void *data) xstrncpy(sslState->server.buf, conn_established, SQUID_TCP_SO_RCVBUF); sslState->server.len = strlen(conn_established); sslState->server.offset = 0; - commSetTimeout(sslState->server.fd, Config.Timeout.read, NULL, NULL); commSetSelect(sslState->client.fd, COMM_SELECT_WRITE, sslWriteClient, @@ -354,6 +344,10 @@ sslConnectDone(int fdnotused, int status, void *data) sslProxyConnected(sslState->server.fd, sslState); else sslConnected(sslState->server.fd, sslState); + commSetTimeout(sslState->server.fd, + Config.Timeout.read, + sslTimeout, + sslState); } } @@ -427,15 +421,14 @@ sslProxyConnected(int fd, void *data) COMM_SELECT_WRITE, sslWriteServer, sslState, 0); - commSetTimeout(fd, Config.Timeout.read, NULL, NULL); + commSetTimeout(sslState->server.fd, + Config.Timeout.read, + sslTimeout, + sslState); commSetSelect(sslState->server.fd, COMM_SELECT_READ, sslReadServer, sslState, 0); - commSetTimeout(sslState->server.fd, - Config.Timeout.read, - NULL, - NULL); } static void diff --git a/src/tunnel.cc b/src/tunnel.cc index 4d3d0f76c4..7b028362d7 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -1,6 +1,6 @@ /* - * $Id: tunnel.cc,v 1.75 1998/03/04 23:52:42 wessels Exp $ + * $Id: tunnel.cc,v 1.76 1998/03/27 22:44:25 wessels Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -130,11 +130,8 @@ sslReadServer(int fd, void *data) commSetSelect(sslState->server.fd, COMM_SELECT_READ, sslReadServer, - sslState, 0); - commSetTimeout(sslState->server.fd, - Config.Timeout.read, - NULL, - NULL); + sslState, + Config.Timeout.read); } else { sslClose(sslState); } @@ -145,11 +142,11 @@ sslReadServer(int fd, void *data) sslState->server.offset = 0; sslState->server.len = len; /* extend server read timeout */ - commSetTimeout(sslState->server.fd, Config.Timeout.read, NULL, NULL); commSetSelect(sslState->client.fd, COMM_SELECT_WRITE, sslWriteClient, - sslState, 0); + sslState, + Config.Timeout.read); } } @@ -225,11 +222,8 @@ sslWriteServer(int fd, void *data) commSetSelect(sslState->client.fd, COMM_SELECT_READ, sslReadClient, - sslState, 0); - commSetTimeout(sslState->server.fd, - Config.Timeout.read, - NULL, - NULL); + sslState, + Config.Timeout.read); } else { /* still have more to write */ commSetSelect(sslState->server.fd, @@ -277,11 +271,8 @@ sslWriteClient(int fd, void *data) commSetSelect(sslState->server.fd, COMM_SELECT_READ, sslReadServer, - sslState, 0); - commSetTimeout(sslState->server.fd, - Config.Timeout.read, - NULL, - NULL); + sslState, + Config.Timeout.read); } else { /* still have more to write */ commSetSelect(sslState->client.fd, @@ -307,7 +298,6 @@ sslConnected(int fd, void *data) xstrncpy(sslState->server.buf, conn_established, SQUID_TCP_SO_RCVBUF); sslState->server.len = strlen(conn_established); sslState->server.offset = 0; - commSetTimeout(sslState->server.fd, Config.Timeout.read, NULL, NULL); commSetSelect(sslState->client.fd, COMM_SELECT_WRITE, sslWriteClient, @@ -354,6 +344,10 @@ sslConnectDone(int fdnotused, int status, void *data) sslProxyConnected(sslState->server.fd, sslState); else sslConnected(sslState->server.fd, sslState); + commSetTimeout(sslState->server.fd, + Config.Timeout.read, + sslTimeout, + sslState); } } @@ -427,15 +421,14 @@ sslProxyConnected(int fd, void *data) COMM_SELECT_WRITE, sslWriteServer, sslState, 0); - commSetTimeout(fd, Config.Timeout.read, NULL, NULL); + commSetTimeout(sslState->server.fd, + Config.Timeout.read, + sslTimeout, + sslState); commSetSelect(sslState->server.fd, COMM_SELECT_READ, sslReadServer, sslState, 0); - commSetTimeout(sslState->server.fd, - Config.Timeout.read, - NULL, - NULL); } static void diff --git a/src/wais.cc b/src/wais.cc index 33638d7ed1..77317197ee 100644 --- a/src/wais.cc +++ b/src/wais.cc @@ -1,6 +1,6 @@ /* - * $Id: wais.cc,v 1.103 1998/03/05 00:43:11 wessels Exp $ + * $Id: wais.cc,v 1.104 1998/03/27 22:44:26 wessels Exp $ * * DEBUG: section 24 WAIS Relay * AUTHOR: Harvest Derived @@ -359,6 +359,7 @@ waisConnectDone(int fd, int status, void *data) comm_close(fd); } else { commSetSelect(fd, COMM_SELECT_WRITE, waisSendRequest, waisState, 0); + commSetTimeout(fd, Config.Timeout.read, waisTimeout, waisState); } }