]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Remember the ICAP OPTIONS fetching transaction so that we can clear/destroy
authorrousskov <>
Tue, 24 Jul 2007 22:43:33 +0000 (22:43 +0000)
committerrousskov <>
Tue, 24 Jul 2007 22:43:33 +0000 (22:43 +0000)
it when it is done, to avoid ICAPOptXactLauncher leak. Use the transaction
pointer instead of the boolean 'waiting' flag.

src/ICAP/ICAPServiceRep.cc
src/ICAP/ICAPServiceRep.h

index 1ed64033396954282daa41d9bd73a1fa5184d425..a25acf7206be90ded5e604c2bc241dd6e4378b38 100644 (file)
@@ -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);
index 755f26f9acc6a3331559f4b6ccaf1deb98e02cb0..a71888e7d5bef388aa8c6efc990d2b5a2abf41f0 100644 (file)
@@ -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