From: rousskov <> Date: Tue, 24 Jul 2007 22:43:33 +0000 (+0000) Subject: Remember the ICAP OPTIONS fetching transaction so that we can clear/destroy X-Git-Tag: SQUID_3_0_PRE7~146 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=98a74c05b0fc17d1d2a80d95d8c4b4141b16e7fa;p=thirdparty%2Fsquid.git Remember the ICAP OPTIONS fetching transaction so that we can clear/destroy it when it is done, to avoid ICAPOptXactLauncher leak. Use the transaction pointer instead of the boolean 'waiting' flag. --- diff --git a/src/ICAP/ICAPServiceRep.cc b/src/ICAP/ICAPServiceRep.cc index 1ed6403339..a25acf7206 100644 --- a/src/ICAP/ICAPServiceRep.cc +++ b/src/ICAP/ICAPServiceRep.cc @@ -16,16 +16,15 @@ CBDATA_CLASS_INIT(ICAPServiceRep); ICAPServiceRep::ICAPServiceRep(): method(ICAP::methodNone), point(ICAP::pointNone), port(-1), bypass(false), - theOptions(NULL), theLastUpdate(0), - theSessionFailures(0), isSuspended(0), - waiting(false), notifying(false), + theOptions(NULL), theOptionsFetcher(0), theLastUpdate(0), + theSessionFailures(0), isSuspended(0), notifying(false), updateScheduled(false), self(NULL), wasAnnouncedUp(true) // do not announce an "up" service at startup {} ICAPServiceRep::~ICAPServiceRep() { - Must(!waiting); + Must(!theOptionsFetcher); changeOptions(0); } @@ -262,7 +261,7 @@ void ICAPServiceRep::noteTimeToUpdate() if (self != NULL) updateScheduled = false; - if (!self || waiting) { + if (!self || theOptionsFetcher) { debugs(93,5, "ICAPService ignores options update " << status()); return; } @@ -318,7 +317,7 @@ void ICAPServiceRep::callWhenReady(Callback *cb, void *data) i.data = cbdataReference(data); theClients.push_back(i); - if (waiting || notifying) + if (theOptionsFetcher || notifying) return; // do nothing, we will be picked up in noteTimeToNotify() if (needNewOptions()) @@ -424,8 +423,8 @@ void ICAPServiceRep::announceStatusChange(const char *downPhrase, bool important // we are receiving ICAP OPTIONS response headers here or NULL on failures void ICAPServiceRep::noteIcapAnswer(HttpMsg *msg) { - Must(waiting); - waiting = false; + Must(theOptionsFetcher); + clearIcap(theOptionsFetcher); Must(msg); @@ -443,8 +442,8 @@ void ICAPServiceRep::noteIcapAnswer(HttpMsg *msg) } void ICAPServiceRep::noteIcapQueryAbort(bool) { - Must(waiting); - waiting = false; + Must(theOptionsFetcher); + clearIcap(theOptionsFetcher); debugs(93,3, "ICAPService failed to fetch options " << status()); handleNewOptions(0); @@ -463,11 +462,10 @@ void ICAPServiceRep::handleNewOptions(ICAPOptions *newOptions) void ICAPServiceRep::startGettingOptions() { - Must(!waiting); + Must(!theOptionsFetcher); debugs(93,6, "ICAPService will get new options " << status()); - waiting = true; - initiateIcap(new ICAPOptXactLauncher(this, self)); + theOptionsFetcher = initiateIcap(new ICAPOptXactLauncher(this, self)); // TODO: timeout in case ICAPOptXact never calls us back? // Such a timeout should probably be a generic AsyncStart feature. } @@ -560,8 +558,8 @@ const char *ICAPServiceRep::status() const buf.append(",stale", 6); } - if (waiting) - buf.append(",wait", 5); + if (theOptionsFetcher) + buf.append(",fetch", 6); if (notifying) buf.append(",notif", 6); diff --git a/src/ICAP/ICAPServiceRep.h b/src/ICAP/ICAPServiceRep.h index 755f26f9ac..a71888e7d5 100644 --- a/src/ICAP/ICAPServiceRep.h +++ b/src/ICAP/ICAPServiceRep.h @@ -1,6 +1,6 @@ /* - * $Id: ICAPServiceRep.h,v 1.10 2007/06/19 21:13:49 rousskov Exp $ + * $Id: ICAPServiceRep.h,v 1.11 2007/07/24 16:43:33 rousskov Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -136,13 +136,13 @@ private: Clients theClients; // all clients waiting for a call back ICAPOptions *theOptions; + ICAPInitiate *theOptionsFetcher; // pending ICAP OPTIONS transaction time_t theLastUpdate; // time the options were last updated static const int TheSessionFailureLimit; int theSessionFailures; const char *isSuspended; // also stores suspension reason for debugging - bool waiting; // for an OPTIONS transaction to finish bool notifying; // may be true in any state except for the initial bool updateScheduled; // time-based options update has been scheduled