--------------------- PatchSet 1917 Date: 2005/10/01 05:48:37 Author: dwsquid Branch: squid3-icap Tag: (none) Log: Make a proper destructor (and constructor) for HttpStateData Members: src/http.cc:1.49.2.40->1.49.2.41 src/http.h:1.11.4.13->1.11.4.14 Index: squid3/src/http.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.cc,v retrieving revision 1.49.2.40 retrieving revision 1.49.2.41 diff -u -r1.49.2.40 -r1.49.2.41 --- squid3/src/http.cc 1 Oct 2005 04:54:09 -0000 1.49.2.40 +++ squid3/src/http.cc 1 Oct 2005 05:48:37 -0000 1.49.2.41 @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.49.2.40 2005/10/01 04:54:09 dwsquid Exp $ + * $Id: http.cc,v 1.49.2.41 2005/10/01 05:48:37 dwsquid Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -57,7 +57,7 @@ #include "ICAPConfig.h" #endif -CBDATA_TYPE(HttpStateData); +CBDATA_CLASS_INIT(HttpStateData); static const char *const crlf = "\r\n"; @@ -78,51 +78,55 @@ static void icapAclCheckDoneWrapper(ICAPServiceRep::Pointer service, void *data); #endif -static void -httpStateFree(int fd, void *data) -{ - HttpStateData *httpState = static_cast(data); - debug(11,5)("httpStateFree: FD %d, httpState=%p\n", fd, data); +HttpStateData::HttpStateData() +{} - if (httpState == NULL) - return; - - if (httpState->request_body_buf) { - if (httpState->orig_request->body_connection.getRaw()) { - clientAbortBody(httpState->orig_request); +HttpStateData::~HttpStateData() +{ + if (request_body_buf) { + if (orig_request->body_connection.getRaw()) { + clientAbortBody(orig_request); } - if (httpState->request_body_buf) { - memFree(httpState->request_body_buf, MEM_8K_BUF); - httpState->request_body_buf = NULL; + if (request_body_buf) { + memFree(request_body_buf, MEM_8K_BUF); + request_body_buf = NULL; } } - storeUnlockObject(httpState->entry); + storeUnlockObject(entry); - if (!httpState->readBuf->isNull()) - httpState->readBuf->clean(); + if (!readBuf->isNull()) + readBuf->clean(); - delete httpState->readBuf; + delete readBuf; - requestUnlink(httpState->request); + requestUnlink(request); - requestUnlink(httpState->orig_request); + requestUnlink(orig_request); - httpState->request = NULL; + request = NULL; - httpState->orig_request = NULL; + orig_request = NULL; #if ICAP_CLIENT - if (httpState->icap) { - delete httpState->icap; - cbdataReferenceDone(httpState->icap); + if (icap) { + delete icap; + cbdataReferenceDone(icap); } #endif +} + +static void +httpStateFree(int fd, void *data) +{ + HttpStateData *httpState = static_cast(data); + debug(11,5)("httpStateFree: FD %d, httpState=%p\n", fd, data); - cbdataFree(httpState); + if (httpState) + delete httpState; } int @@ -1133,6 +1137,7 @@ #if ICAP_CLIENT if (icapAccessCheckPending) return; + #endif /* @@ -1800,8 +1805,7 @@ debug(11, 3) ("httpStart: \"%s %s\"\n", RequestMethodStr[orig_req->method], storeUrl(fwd->entry)); - CBDATA_INIT_TYPE(HttpStateData); - httpState = cbdataAlloc(HttpStateData); + httpState = new HttpStateData; httpState->ignoreCacheControl = false; httpState->surrogateNoStore = false; storeLockObject(fwd->entry); Index: squid3/src/http.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.h,v retrieving revision 1.11.4.13 retrieving revision 1.11.4.14 diff -u -r1.11.4.13 -r1.11.4.14 --- squid3/src/http.h 1 Oct 2005 04:54:09 -0000 1.11.4.13 +++ squid3/src/http.h 1 Oct 2005 05:48:38 -0000 1.11.4.14 @@ -1,6 +1,6 @@ /* - * $Id: http.h,v 1.11.4.13 2005/10/01 04:54:09 dwsquid Exp $ + * $Id: http.h,v 1.11.4.14 2005/10/01 05:48:38 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -46,7 +46,8 @@ { public: - ~HttpStateData() { assert(NULL == reply); }; + HttpStateData(); + ~HttpStateData(); static CWCB SendComplete; /* should be private */ @@ -119,6 +120,9 @@ int doIcap(ICAPServiceRep::Pointer); #endif + +private: + CBDATA_CLASS2(HttpStateData); }; #endif /* SQUID_HTTP_H */