From: Alex Rousskov Date: Mon, 26 Aug 2013 18:24:02 +0000 (-0600) Subject: Added ftp_client_idle_timeout directive to squid.conf. X-Git-Tag: SQUID_3_5_0_1~117^2~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6e8754a27de89d16713128596daafa147c09cda;p=thirdparty%2Fsquid.git Added ftp_client_idle_timeout directive to squid.conf. Many FTP clients do not deal with control connection closures. They cannot retry pconn races without asking the user for credentials, for example. Thus, the existing client_idle_pconn_timeout default (2 minutes) does not work well for FTP clients. One the other hand, increasing that may create too many idle HTTP connections for Squid to maintain. The new timeout is specific to ftp_port traffic. It does not affect ftp://... requests sent to an http[s]_port. --- diff --git a/src/SquidConfig.h b/src/SquidConfig.h index 5f4fab694d..7e46035622 100644 --- a/src/SquidConfig.h +++ b/src/SquidConfig.h @@ -108,6 +108,7 @@ public: time_t request; time_t clientIdlePconn; time_t serverIdlePconn; + time_t ftpClientIdle; time_t siteSelect; time_t deadPeer; int icp_query; /* msec */ diff --git a/src/cf.data.pre b/src/cf.data.pre index dbd6217e23..f558709659 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -5440,6 +5440,17 @@ DOC_START client connection after the previous request completes. DOC_END +NAME: ftp_client_idle_timeout +TYPE: time_t +LOC: Config.Timeout.ftpClientIdle +DEFAULT: 30 minutes +DOC_START + How long to wait for an FTP request on a connection to Squid ftp_port. + Many FTP clients do not deal with idle connection closures well, + necessitating a longer default timeout than client_idle_pconn_timeout + used for incoming HTTP requests. +DOC_END + NAME: client_lifetime COMMENT: time-units TYPE: time_t diff --git a/src/client_side.cc b/src/client_side.cc index 038996b216..10a0d49ff2 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1610,7 +1610,9 @@ ConnStateData::readNextRequest() typedef CommCbMemFunT TimeoutDialer; AsyncCall::Pointer timeoutCall = JobCallback(33, 5, TimeoutDialer, this, ConnStateData::requestTimeout); - commSetConnTimeout(clientConnection, Config.Timeout.clientIdlePconn, timeoutCall); + const int timeout = isFtp ? Config.Timeout.ftpClientIdle : + Config.Timeout.clientIdlePconn; + commSetConnTimeout(clientConnection, timeout, timeoutCall); readSomeData(); /** Please don't do anything with the FD past here! */ @@ -4960,9 +4962,15 @@ static void FtpChangeState(ConnStateData *connState, const ConnStateData::FtpState newState, const char *reason) { assert(connState); - debugs(33, 3, "client state was " << connState->ftp.state << ", now " << - newState << " because " << reason); - connState->ftp.state = newState; + if (connState->ftp.state == newState) { + debugs(33, 3, "client state unchanged at " << connState->ftp.state << + " because " << reason); + connState->ftp.state = newState; + } else { + debugs(33, 3, "client state was " << connState->ftp.state << + ", now " << newState << " because " << reason); + connState->ftp.state = newState; + } } /** Parse an FTP request