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.
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);
}
HttpMsg *
HttpMsg::_lock()
{
- ++lock_count;
+ lock();
return this;
}
void
HttpMsg::_unlock()
{
- assert(lock_count > 0);
- --lock_count;
-
- if (0 == lock_count)
+ if (unlock() == 0)
delete this;
}
#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:
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);