]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix lock-counting bug caused by mixing references with this lock counting
authorwessels <>
Tue, 24 Jan 2006 04:36:07 +0000 (04:36 +0000)
committerwessels <>
Tue, 24 Jan 2006 04:36:07 +0000 (04:36 +0000)
technique.

Also added locks for HttpReply in ICAPAccessCheck::ICAPAccessCheck()

src/ICAP/ICAPConfig.cc
src/ICAP/ICAPModXact.cc
src/ICAP/MsgPipeData.h

index ec4f6336b75dc70ce97220b2874a5022d2bd44bc..61cf6ee322d9fc7e31cc1d1fda768b41f8a4e83f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ICAPConfig.cc,v 1.4 2005/12/02 19:43:38 wessels Exp $
+ * $Id: ICAPConfig.cc,v 1.5 2006/01/23 21:36:07 wessels Exp $
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
  * ----------------------------------------------------------
@@ -41,6 +41,7 @@
 #include "ICAPConfig.h"
 #include "ICAPServiceRep.h"
 #include "HttpRequest.h"
+#include "HttpReply.h"
 #include "ACLChecklist.h"
 
 ICAPConfig TheICAPConfig;
@@ -113,13 +114,23 @@ ICAPAccessCheck::ICAPAccessCheck(ICAP::Method aMethod,
 {
     method = aMethod;
     point = aPoint;
-    req = requestLink(aReq);
-    rep = aRep;
+
+    req = aReq->lock()
+
+          ;
+    rep = aRep ? aRep->lock()
+          : NULL;
+
     callback = aCallback;
+
     callback_data = aCallbackData;
+
     candidateClasses.clean();
+
     matchedClass.clean();
+
     acl_checklist = NULL;
+
     debug(93,5)("ICAPAccessCheck constructed for %s %s\n",
                 ICAP::methodStr(method),
                 ICAP::vectPointStr(point));
@@ -127,7 +138,11 @@ ICAPAccessCheck::ICAPAccessCheck(ICAP::Method aMethod,
 
 ICAPAccessCheck::~ICAPAccessCheck()
 {
-    requestUnlink(req);
+    if (req)
+        req->unlock();
+
+    if (rep)
+        rep->unlock();
 }
 
 /*
index d5f22a9241a03f3ed09e9497ea98c3024e488820..3559d443ffba309f8abb1dd6e5813d4def5fed9e 100644 (file)
@@ -683,8 +683,8 @@ void ICAPModXact::handle204NoContent()
     packHead(httpBuf, oldHead);
 
     // allocate the adapted message
-    HttpMsg *&newHead = adapted->data->header;
-    Must(!newHead);
+    Must(!adapted->data->header);
+    HttpMsg *newHead = NULL;
 
     if (dynamic_cast<const HttpRequest*>(oldHead))
         newHead = new HttpRequest;
@@ -694,6 +694,8 @@ void ICAPModXact::handle204NoContent()
 
     Must(newHead);
 
+    adapted->data->setHeader(newHead);
+
     // parse the buffer back
     http_status error = HTTP_STATUS_NONE;
 
index cbc56589a0ffaf5e5d296b63421ceb736a0fde07..06fd23539cdcdfb7c0a1b261aa41905c42cc5052 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: MsgPipeData.h,v 1.5 2006/01/23 20:04:25 wessels Exp $
+ * $Id: MsgPipeData.h,v 1.6 2006/01/23 21:36:07 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -65,6 +65,7 @@ public:
 
     void setCause(HttpRequest *r)
     {
+        clearCause();
 
         cause = r->lock()
 
@@ -93,9 +94,9 @@ public:
 
 private:
 
-    void clearCause() { cause->unlock(); cause = NULL; };
+    void clearCause() { if (cause) { cause->unlock(); cause = NULL; } };
 
-    void clearHeader() { header->unlock(); header = NULL; };
+    void clearHeader() { if (header) { header->unlock(); header = NULL; } };
 };
 
 #endif /* SQUID_MSGPIPEDATA_H */