]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Send RST packet when closing an ICAP connection after a transaction error.
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 6 Sep 2011 17:57:57 +0000 (11:57 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Tue, 6 Sep 2011 17:57:57 +0000 (11:57 -0600)
This helps identify abnormal transaction termination at the ICAP server. The
code is from a production-running branch and was proven useful in some
environments (especially if the ICAP service needs help correctly dealing with
prematurely terminated transfers), but it is not yet clear whether the
advantages of doing this on a regular basis outweigh the overheads. If not,
we will need a squid.conf parameter to control connection closing behavior.

src/adaptation/icap/ServiceRep.cc
src/adaptation/icap/ServiceRep.h
src/adaptation/icap/Xaction.cc

index 2cdbb594541faefb0497c694322bac0f07dc933c..d4028c18e516a43412534d4444200fa1973b8df0 100644 (file)
@@ -115,7 +115,7 @@ Adaptation::Icap::ServiceRep::getConnection(bool retriableXact, bool &reused)
 }
 
 // pools connection if it is reusable or closes it
-void Adaptation::Icap::ServiceRep::putConnection(const Comm::ConnectionPointer &conn, bool isReusable, const char *comment)
+void Adaptation::Icap::ServiceRep::putConnection(const Comm::ConnectionPointer &conn, bool isReusable, bool sendReset, const char *comment)
 {
     Must(Comm::IsConnOpen(conn));
     // do not pool an idle connection if we owe connections
@@ -124,9 +124,14 @@ void Adaptation::Icap::ServiceRep::putConnection(const Comm::ConnectionPointer &
         commUnsetConnTimeout(conn);
         theIdleConns->push(conn);
     } else {
-        debugs(93, 3, HERE << "closing pconn" << comment);
-        // comm_close will clear timeout
-        conn->close();
+        debugs(93, 3, HERE << (sendReset ? "RST" : "FIN") << "-closing " <<
+               comment);
+        // comm_close called from Connection::close will clear timeout
+        // TODO: add "bool sendReset = false" to Connection::close()?
+        if (sendReset)
+            comm_reset_close(conn);
+        else
+            conn->close();
     }
 
     Must(theBusyConns > 0);
index f7c342469fa39ae1938da3f79f9a70c0f4f1a789..f39e2f4e6bcf75fd3e65deb4dd411506f5e866d9 100644 (file)
@@ -111,7 +111,7 @@ public:
     bool allows204() const;
     bool allows206() const;
     Comm::ConnectionPointer getConnection(bool isRetriable, bool &isReused);
-    void putConnection(const Comm::ConnectionPointer &conn, bool isReusable, const char *comment);
+    void putConnection(const Comm::ConnectionPointer &conn, bool isReusable, bool sendReset, const char *comment);
     void noteConnectionUse(const Comm::ConnectionPointer &conn);
     void noteConnectionFailed(const char *comment);
 
index 58d9f9d77772f90ac0740fceb27185e048d3d0b8..6a01aad1bfd23d10f9e4a1a21cb828b534b53a2d 100644 (file)
@@ -204,8 +204,11 @@ void Adaptation::Icap::Xaction::closeConnection()
         if (reuseConnection)
             disableRetries();
 
+        const bool reset = !reuseConnection &&
+            (al.icap.outcome == xoGone || al.icap.outcome == xoError);
+
         Adaptation::Icap::ServiceRep &s = service();
-        s.putConnection(connection, reuseConnection, status());
+        s.putConnection(connection, reuseConnection, reset, status());
 
         writer = NULL;
         reader = NULL;