From: Amos Jeffries Date: Tue, 5 Feb 2013 07:47:28 +0000 (+1300) Subject: Migrate HttpMsg to Lock refcounting X-Git-Tag: SQUID_3_4_0_1~308 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5444ee4802d1dbec0405af2974ac6b8b7aeac54d;p=thirdparty%2Fsquid.git Migrate HttpMsg to Lock refcounting First stage of the conversion to RefCount<>. This replaces the custom attempt at ref-count locking in HttpMsg with the locking mechanism presented by class Lock. --- diff --git a/src/HttpMsg.cc b/src/HttpMsg.cc index 88d22f0f63..e640592fd8 100644 --- a/src/HttpMsg.cc +++ b/src/HttpMsg.cc @@ -42,12 +42,11 @@ HttpMsg::HttpMsg(http_hdr_owner_type owner): header(owner), cache_control(NULL), hdr_sz(0), content_length(0), protocol(AnyP::PROTO_NONE), - pstate(psReadyToParseStartLine), lock_count(0) + pstate(psReadyToParseStartLine) {} HttpMsg::~HttpMsg() { - assert(lock_count == 0); assert(!body_pipe); } @@ -363,7 +362,7 @@ void HttpMsg::firstLineBuf(MemBuf& mb) HttpMsg * HttpMsg::_lock() { - ++lock_count; + lock(); return this; } @@ -371,9 +370,6 @@ HttpMsg::_lock() void HttpMsg::_unlock() { - assert(lock_count > 0); - --lock_count; - - if (0 == lock_count) + if (unlock() == 0) delete this; } diff --git a/src/HttpMsg.h b/src/HttpMsg.h index aaed1240e2..6eb09c84fd 100644 --- a/src/HttpMsg.h +++ b/src/HttpMsg.h @@ -31,19 +31,20 @@ #ifndef SQUID_HTTPMSG_H #define SQUID_HTTPMSG_H -#include "typedefs.h" +#include "base/Lock.h" +#include "BodyPipe.h" #include "HttpHeader.h" #include "HttpRequestMethod.h" #include "HttpStatusCode.h" #include "HttpVersion.h" -#include "BodyPipe.h" +#include "typedefs.h" // common parts of HttpRequest and HttpReply template class HttpMsgPointerT; -class HttpMsg +class HttpMsg : public RefCountable { public: @@ -125,9 +126,6 @@ protected: virtual bool parseFirstLine(const char *blk_start, const char *blk_end) = 0; virtual void hdrCacheInit(); - - int lock_count; - }; int httpMsgIsolateHeaders(const char **parse_start, int len, const char **blk_start, const char **blk_end);