]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added ftp_client_idle_timeout directive to squid.conf.
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 26 Aug 2013 18:24:02 +0000 (12:24 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 26 Aug 2013 18:24:02 +0000 (12:24 -0600)
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.

src/SquidConfig.h
src/cf.data.pre
src/client_side.cc

index 5f4fab694d5d3a05ea4b53ff9c566748f94f25a6..7e460356222d8e08ba462a8fd90f4b41e678baa5 100644 (file)
@@ -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 */
index dbd6217e23762c3155432fcf6513e468ee26cd49..f5587096594150af920bd811f78e42023f1954b3 100644 (file)
@@ -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
index 038996b21693880e0859442d1ff9c059b2303d38..10a0d49ff24c2d133ca6c9c9cb4acafaaf765c80 100644 (file)
@@ -1610,7 +1610,9 @@ ConnStateData::readNextRequest()
     typedef CommCbMemFunT<ConnStateData, CommTimeoutCbParams> 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