]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
bug: ICAPAccessCheck should use cbdataReference and cbdataReferenceValidDone
authorwessels <>
Fri, 12 May 2006 05:53:13 +0000 (05:53 +0000)
committerwessels <>
Fri, 12 May 2006 05:53:13 +0000 (05:53 +0000)
in case the upstream ClientRequestContext goes away during processing.

src/ICAP/ICAPConfig.cc
src/client_side_request.cc

index 57b65061a1aa23c09c938f527ac252964c8ad62f..06ec2ba00de13b87cc295d1c4b83994f48cdd804 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ICAPConfig.cc,v 1.10 2006/04/28 05:05:47 wessels Exp $
+ * $Id: ICAPConfig.cc,v 1.11 2006/05/11 23:53:13 wessels Exp $
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
  * ----------------------------------------------------------
@@ -121,7 +121,7 @@ ICAPAccessCheck::ICAPAccessCheck(ICAP::Method aMethod,
 
     callback = aCallback;
 
-    callback_data = aCallbackData;
+    callback_data = cbdataReference(aCallbackData);
 
     candidateClasses.clean();
 
@@ -270,6 +270,13 @@ ICAPAccessCheck::do_callback()
 
     matchedClass.clean();
 
+    void *validated_cbdata;
+
+    if (!cbdataReferenceValidDone(callback_data, &validated_cbdata)) {
+        debugs(93,3,HERE << "do_callback: callback_data became invalid, skipping");
+        return;
+    }
+
     Vector<ICAPServiceRep::Pointer>::iterator i;
 
     for (i = theClass->services.begin(); i != theClass->services.end(); ++i) {
@@ -281,7 +288,7 @@ ICAPAccessCheck::do_callback()
         if (point != theService->point)
             continue;
 
-        callback(*i, callback_data);
+        callback(*i, validated_cbdata);
 
         return;
     }
index 2650461bad40f1be851cfee0374f9adfc714e2d9..ecee9fc1ff668e2850a9f32d2515b5d82dc3fbd9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_request.cc,v 1.65 2006/05/08 23:38:33 robertc Exp $
+ * $Id: client_side_request.cc,v 1.66 2006/05/11 23:53:13 wessels Exp $
  * 
  * DEBUG: section 85    Client-side Request Routines
  * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
@@ -119,6 +119,8 @@ ClientRequestContext::~ClientRequestContext()
             delete acl_checklist;
         }
     }
+
+    debugs(85,3, HERE << this << " ClientHttpRequest destructed");
 }
 
 ClientRequestContext::ClientRequestContext(ClientHttpRequest *anHttp) : http(anHttp), acl_checklist (NULL), redirect_state (REDIRECT_NONE)
@@ -128,6 +130,7 @@ ClientRequestContext::ClientRequestContext(ClientHttpRequest *anHttp) : http(anH
     redirect_done = false;
     no_cache_done = false;
     interpreted_req_hdrs = false;
+    debugs(85,3, HERE << this << " ClientHttpRequest constructed");
 }
 
 CBDATA_CLASS_INIT(ClientHttpRequest);
@@ -504,6 +507,7 @@ icapAclCheckDoneWrapper(ICAPServiceRep::Pointer service, void *data)
 void
 ClientRequestContext::icapAclCheckDone(ICAPServiceRep::Pointer service)
 {
+    debugs(93,3,HERE << this << " icapAclCheckDone called");
     /*
      * No matching ICAP service in the config file
      */
@@ -517,6 +521,8 @@ ClientRequestContext::icapAclCheckDone(ICAPServiceRep::Pointer service)
      * Setup ICAP state and such.  If successful, just return.
      * We'll get back to doCallouts() after REQMOD is done.
      */
+    assert(http);
+
     if (0 == http->doIcap(service))
         return;
 
@@ -1111,7 +1117,7 @@ ClientHttpRequest::doCallouts()
 int
 ClientHttpRequest::doIcap(ICAPServiceRep::Pointer service)
 {
-    debug(85,3)("ClientHttpRequest::doIcap() called\n");
+    debugs(85,3, HERE << this << " ClientHttpRequest::doIcap() called");
     assert(NULL == icap);
     icap = new ICAPClientReqmodPrecache(service);
     (void) cbdataReference(icap);