]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Changed comm connect routines so that the timeout value and handler
authorwessels <>
Sat, 28 Mar 1998 05:44:18 +0000 (05:44 +0000)
committerwessels <>
Sat, 28 Mar 1998 05:44:18 +0000 (05:44 +0000)
are CLEARED when connection succeeds.  This means all the connect
callback (CNCB) functions need to re-set the timeout handlers.

src/asn.cc
src/ftp.cc
src/gopher.cc
src/http.cc
src/ident.cc
src/ssl.cc
src/tunnel.cc
src/wais.cc

index 59b90702d278335afa001d472653379b49e4c3e3..face8dd2883182e6749d1557b2ade28655101013 100644 (file)
@@ -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
index 9dff3b0aca8de6ca40af0a9ead62badaad8a4ea6..5b31a4fca7c2492e5a4ceaff4e3eb50e27316aca 100644 (file)
@@ -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);
     }
 }
 
index 3496fd4ae4d037acc441c1ed7e58f0a22e6f46aa..51c5ae5518f210a5dcaa9951eef7b273ada9fdb6 100644 (file)
@@ -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);
     }
 }
 
index 58341b4b033794bc180a4fc84ce56045c9bd3d3c..b3d6fdbe479cf6ef2bc3087bc58e2133ec1486a0 100644 (file)
@@ -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);
     }
 }
 
index a81b525b63f911bd92b2215354df426e04938e00..860689d9556410d99762c1c6964b08be68f70480 100644 (file)
@@ -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
index 341358b01307c48f94214a98a523a0fe3e431f27..213763c1c4b651d6462217f2c0a5f3ea4f87fb48 100644 (file)
@@ -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
index 4d3d0f76c4dafccd64b89b2870af6ae3a96478dc..7b028362d77b61415dc116541c92faa89ff7e212 100644 (file)
@@ -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
index 33638d7ed10ad91a32e84def0cbb80bd46741ece..77317197ee4b13e3631418bc4b442b2742da754a 100644 (file)
@@ -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);
     }
 }