]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3688: Lots of Orphan Comm:Connections to ICAP server
authorAlexander Komyagin <komyagin@altell.ru>
Sun, 2 Dec 2012 08:17:17 +0000 (01:17 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 2 Dec 2012 08:17:17 +0000 (01:17 -0700)
src/adaptation/icap/Xaction.cc
src/adaptation/icap/Xaction.h
src/comm/ConnOpener.h

index 21e9cee53cbf4370c7658fad1333825e5d6e54c1..1d87b57dfd734e936bb8ce4dab803390667abf30 100644 (file)
@@ -42,7 +42,8 @@ Adaptation::Icap::Xaction::Xaction(const char *aTypeName, Adaptation::Icap::Serv
         ignoreLastWrite(false),
         connector(NULL), reader(NULL), writer(NULL), closer(NULL),
         alep(new AccessLogEntry),
-        al(*alep)
+        al(*alep),
+        cs(NULL)
 {
     debugs(93,3, typeName << " constructed, this=" << this <<
            " [icapx" << id << ']'); // we should not call virtual status() here
@@ -167,7 +168,7 @@ Adaptation::Icap::Xaction::dnsLookupDone(const ipcache_addrs *ia)
     // TODO: service bypass status may differ from that of a transaction
     typedef CommCbMemFunT<Adaptation::Icap::Xaction, CommConnectCbParams> ConnectDialer;
     connector = JobCallback(93,3, ConnectDialer, this, Adaptation::Icap::Xaction::noteCommConnected);
-    Comm::ConnOpener *cs = new Comm::ConnOpener(connection, connector, TheConfig.connect_timeout(service().cfg().bypass));
+    cs = new Comm::ConnOpener(connection, connector, TheConfig.connect_timeout(service().cfg().bypass));
     cs->setHost(s.cfg().host.termedBuf());
     AsyncJob::Start(cs);
 }
@@ -222,6 +223,8 @@ void Adaptation::Icap::Xaction::closeConnection()
 // connection with the ICAP service established
 void Adaptation::Icap::Xaction::noteCommConnected(const CommConnectCbParams &io)
 {
+    cs = NULL;
+
     if (io.flag == COMM_TIMEOUT) {
         handleCommTimedout();
         return;
@@ -506,6 +509,12 @@ void Adaptation::Icap::Xaction::setOutcome(const Adaptation::Icap::XactOutcome &
 void Adaptation::Icap::Xaction::swanSong()
 {
     // kids should sing first and then call the parent method.
+    if (cs) {
+        debugs(93,6, HERE << id << " about to notify ConnOpener!");
+        CallJobHere(93, 3, cs, Comm::ConnOpener, noteAbort);
+        cs = NULL;
+        service().noteConnectionFailed("abort");
+    }
 
     closeConnection(); // TODO: rename because we do not always close
 
index 66d2bd21c46e63fc0fb2443215f6397d028c510a..490d3a4835dbf3d17484c8afe0bc46792b3c5c5b 100644 (file)
 #include "ipcache.h"
 
 class CommConnectCbParams;
+namespace Comm
+{
+class ConnOpener;
+}
 
 namespace Adaptation
 {
@@ -188,6 +192,7 @@ protected:
     timeval icap_tio_finish;   /*time when the last byte of the ICAP responsewas received*/
 
 private:
+    Comm::ConnOpener *cs;
     //CBDATA_CLASS2(Xaction);
 };
 
index 25c2b9a2b6a43cafe12378ba37be698ad7e40828..45e4c41287a388ac5c6b0abcd4af8d27d2c7a32c 100644 (file)
@@ -21,6 +21,8 @@ protected:
     virtual void swanSong();
 
 public:
+    void noteAbort() { mustStop("externally aborted"); }
+
     typedef CbcPointer<ConnOpener> Pointer;
 
     virtual bool doneAll() const;