From 7514268ebbc43b8c37d8ae22d86e96da3eee202d Mon Sep 17 00:00:00 2001 From: wessels <> Date: Tue, 24 Jan 2006 04:36:07 +0000 Subject: [PATCH] Fix lock-counting bug caused by mixing references with this lock counting technique. Also added locks for HttpReply in ICAPAccessCheck::ICAPAccessCheck() --- src/ICAP/ICAPConfig.cc | 23 +++++++++++++++++++---- src/ICAP/ICAPModXact.cc | 6 ++++-- src/ICAP/MsgPipeData.h | 7 ++++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/ICAP/ICAPConfig.cc b/src/ICAP/ICAPConfig.cc index ec4f6336b7..61cf6ee322 100644 --- a/src/ICAP/ICAPConfig.cc +++ b/src/ICAP/ICAPConfig.cc @@ -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(); } /* diff --git a/src/ICAP/ICAPModXact.cc b/src/ICAP/ICAPModXact.cc index d5f22a9241..3559d443ff 100644 --- a/src/ICAP/ICAPModXact.cc +++ b/src/ICAP/ICAPModXact.cc @@ -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(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; diff --git a/src/ICAP/MsgPipeData.h b/src/ICAP/MsgPipeData.h index cbc56589a0..06fd23539c 100644 --- a/src/ICAP/MsgPipeData.h +++ b/src/ICAP/MsgPipeData.h @@ -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 */ -- 2.39.5