]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Migrate HttpMsg to Lock refcounting
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 5 Feb 2013 07:47:28 +0000 (20:47 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 5 Feb 2013 07:47:28 +0000 (20:47 +1300)
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.

src/HttpMsg.cc
src/HttpMsg.h

index 88d22f0f631a76635c60f348573cea3d0c119aa9..e640592fd821a32db28e2db5ddeac53c4fa4787a 100644 (file)
 
 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;
 }
index aaed1240e2d9fc15f17c10df105f1447f474c6d4..6eb09c84fd6eff3c5712a0a779a1c8f88a1b1799 100644 (file)
 #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 Msg>
 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);