From: Alexander Komyagin Date: Sun, 2 Dec 2012 07:27:40 +0000 (-0700) Subject: Bug 3688: Lots of Orphan Comm:Connections to ICAP server X-Git-Tag: SQUID_3_3_0_2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d69c380315581c92162ae80a35783e24869f9df;p=thirdparty%2Fsquid.git Bug 3688: Lots of Orphan Comm:Connections to ICAP server --- diff --git a/src/adaptation/icap/Xaction.cc b/src/adaptation/icap/Xaction.cc index 94d3d4e97f..34238f260d 100644 --- a/src/adaptation/icap/Xaction.cc +++ b/src/adaptation/icap/Xaction.cc @@ -45,7 +45,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 @@ -170,7 +171,7 @@ Adaptation::Icap::Xaction::dnsLookupDone(const ipcache_addrs *ia) // TODO: service bypass status may differ from that of a transaction typedef CommCbMemFunT 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); } @@ -225,6 +226,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; @@ -508,6 +511,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 diff --git a/src/adaptation/icap/Xaction.h b/src/adaptation/icap/Xaction.h index 4e9a03e575..0dd6938445 100644 --- a/src/adaptation/icap/Xaction.h +++ b/src/adaptation/icap/Xaction.h @@ -42,6 +42,10 @@ #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); }; diff --git a/src/comm/ConnOpener.h b/src/comm/ConnOpener.h index 25c2b9a2b6..45e4c41287 100644 --- a/src/comm/ConnOpener.h +++ b/src/comm/ConnOpener.h @@ -21,6 +21,8 @@ protected: virtual void swanSong(); public: + void noteAbort() { mustStop("externally aborted"); } + typedef CbcPointer Pointer; virtual bool doneAll() const;