From: hno <> Date: Sun, 10 Oct 2004 08:49:04 +0000 (+0000) Subject: Bug #848: connect_timeout ends up twice the length X-Git-Tag: SQUID_3_0_PRE4~1029 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=777831e0b206858ca5aaafeb426ed036ce713c94;p=thirdparty%2Fsquid.git Bug #848: connect_timeout ends up twice the length 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. --- diff --git a/src/cf.data.pre b/src/cf.data.pre index e3fe814a74..5fbea85db1 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -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 diff --git a/src/forward.cc b/src/forward.cc index 230316033d..0c50f9269d 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -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); diff --git a/src/structs.h b/src/structs.h index 3a19572072..751c497f31 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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;