]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #848: connect_timeout ends up twice the length
authorhno <>
Sun, 10 Oct 2004 08:49:04 +0000 (08:49 +0000)
committerhno <>
Sun, 10 Oct 2004 08:49:04 +0000 (08:49 +0000)
This adds the forward_timeout parameter, placing an upper limit on
how long Squid tries to forward a request, and allows proper connect
timeout management.

src/cf.data.pre
src/forward.cc
src/structs.h

index e3fe814a74ceb0b4dacb4a146ba6ede7639f5b65..5fbea85db1e4aac877529e76aae744833d782a11 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.358 2004/10/08 17:42:09 hno Exp $
+# $Id: cf.data.pre,v 1.359 2004/10/10 02:49:04 hno Exp $
 #
 #
 # SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -2231,17 +2231,25 @@ COMMENT_START
  -----------------------------------------------------------------------------
 COMMENT_END
 
+NAME: forward_timeout
+COMMENT: time-units
+TYPE: time_t
+LOC: Config.Timeout.forward
+DEFAULT: 4 minutes
+DOC_START
+    This parameter specifies how long Squid should at most attempt in
+    finding a forwarding path for the request before giving up.
+DOC_END
+
 NAME: connect_timeout
 COMMENT: time-units
 TYPE: time_t
 LOC: Config.Timeout.connect
-DEFAULT: 2 minutes
+DEFAULT: 1 minute
 DOC_START
-       Some systems (notably Linux) can not be relied upon to properly
-       time out connect(2) requests.  Therefore the Squid process
-       enforces its own timeout on server connections.  This parameter
-       specifies how long to wait for the connect to complete.  The
-       default is two minutes (120 seconds).
+    This parameter specifies how long to wait for the TCP connect to
+    the requested server or peer to complete before Squid should
+    attempt to find another path where to forward the request.
 DOC_END
 
 NAME: peer_connect_timeout
index 230316033dd7966dbd8eb6f4530e2f40914d2f48..0c50f9269d143b431357a82bfcae59d47310c257 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.cc,v 1.119 2004/09/25 15:52:59 hno Exp $
+ * $Id: forward.cc,v 1.120 2004/10/10 02:49:05 hno Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -165,7 +165,7 @@ fwdCheckRetry(FwdState * fwdState)
     if (fwdState->origin_tries > 2)
         return 0;
 
-    if (squid_curtime - fwdState->start > Config.Timeout.connect)
+    if (squid_curtime - fwdState->start > Config.Timeout.forward)
         return 0;
 
     if (fwdState->flags.dont_retry)
@@ -556,7 +556,8 @@ fwdConnectStart(void *data)
     const char *host;
     unsigned short port;
     const char *domain = NULL;
-    time_t ctimeout;
+    int ctimeout;
+    int ftimeout = Config.Timeout.forward - (squid_curtime - fwdState->start);
 
     struct in_addr outgoing;
     unsigned short tos;
@@ -578,6 +579,12 @@ fwdConnectStart(void *data)
         ctimeout = Config.Timeout.connect;
     }
 
+    if (ftimeout < 0)
+        ftimeout = 5;
+
+    if (ftimeout < ctimeout)
+        ctimeout = ftimeout;
+
     if ((fd = pconnPop(host, port, domain)) >= 0) {
         if (fwdCheckRetriable(fwdState)) {
             debug(17, 3) ("fwdConnectStart: reusing pconn FD %d\n", fd);
index 3a19572072031a4891dc19fcda2ddd45c8d8da27..751c497f3182a978e1916786378348817b1ae599 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.490 2004/09/25 15:46:45 hno Exp $
+ * $Id: structs.h,v 1.491 2004/10/10 02:49:05 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -258,6 +258,7 @@ struct _SquidConfig
         time_t read;
         time_t lifetime;
         time_t connect;
+        time_t forward;
         time_t peer_connect;
         time_t request;
         time_t persistent_request;