--------------------- PatchSet 1906 Date: 2005/09/30 20:58:11 Author: dwsquid Branch: squid3-icap Tag: (none) Log: Mostly just debugging changes and comments. Also make it clear that ICAPAnchor takes on responsibility for the fate of adapted->data->header. Either hand it off to HttpStateData, or delete it. Members: src/HttpMsg.h:1.1.2.5->1.1.2.6 src/HttpReply.cc:1.21.4.10->1.21.4.11 src/HttpReply.h:1.8.10.9->1.8.10.10 src/HttpRequest.cc:1.16.4.8->1.16.4.9 src/HttpRequest.h:1.13.4.6->1.13.4.7 src/ICAPAnchor.cc:1.1.2.29->1.1.2.30 src/ICAPConfig.cc:1.1.2.4->1.1.2.5 src/ICAPXaction.cc:1.1.2.35->1.1.2.36 src/http.cc:1.49.2.37->1.49.2.38 Index: squid3/src/HttpMsg.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpMsg.h,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- squid3/src/HttpMsg.h 29 Sep 2005 22:56:59 -0000 1.1.2.5 +++ squid3/src/HttpMsg.h 30 Sep 2005 20:58:11 -0000 1.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: HttpMsg.h,v 1.1.2.5 2005/09/29 22:56:59 dwsquid Exp $ + * $Id: HttpMsg.h,v 1.1.2.6 2005/09/30 20:58:11 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -45,7 +45,7 @@ public: HttpMsg(http_hdr_owner_type owner); - virtual ~HttpMsg() {} + virtual ~HttpMsg() {}; virtual void reset() = 0; // will have body when http*Clean()s are gone @@ -72,7 +72,7 @@ bool parse(MemBuf *buf, bool eol, http_status *error); int httpMsgParseStep(const char *buf, int atEnd); int httpMsgParseError(); - virtual bool expectingBody(method_t, ssize_t&) = 0; + virtual bool expectingBody(method_t, ssize_t&) const = 0; protected: Index: squid3/src/HttpReply.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpReply.cc,v retrieving revision 1.21.4.10 retrieving revision 1.21.4.11 diff -u -r1.21.4.10 -r1.21.4.11 --- squid3/src/HttpReply.cc 29 Sep 2005 22:56:59 -0000 1.21.4.10 +++ squid3/src/HttpReply.cc 30 Sep 2005 20:58:11 -0000 1.21.4.11 @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.cc,v 1.21.4.10 2005/09/29 22:56:59 dwsquid Exp $ + * $Id: HttpReply.cc,v 1.21.4.11 2005/09/30 20:58:11 dwsquid Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -523,7 +523,7 @@ * along with this response */ bool -HttpReply::expectingBody(method_t req_method, ssize_t& theSize) +HttpReply::expectingBody(method_t req_method, ssize_t& theSize) const { bool expectBody = true; Index: squid3/src/HttpReply.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpReply.h,v retrieving revision 1.8.10.9 retrieving revision 1.8.10.10 diff -u -r1.8.10.9 -r1.8.10.10 --- squid3/src/HttpReply.h 29 Sep 2005 22:56:59 -0000 1.8.10.9 +++ squid3/src/HttpReply.h 30 Sep 2005 20:58:11 -0000 1.8.10.10 @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.h,v 1.8.10.9 2005/09/29 22:56:59 dwsquid Exp $ + * $Id: HttpReply.h,v 1.8.10.10 2005/09/30 20:58:11 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -109,7 +109,7 @@ public: void httpReplyUpdateOnNotModified(HttpReply const *other); - virtual bool expectingBody(method_t, ssize_t&); + virtual bool expectingBody(method_t, ssize_t&) const; protected: virtual void packFirstLineInto(Packer * p, bool) const; Index: squid3/src/HttpRequest.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpRequest.cc,v retrieving revision 1.16.4.8 retrieving revision 1.16.4.9 diff -u -r1.16.4.8 -r1.16.4.9 --- squid3/src/HttpRequest.cc 29 Sep 2005 22:56:59 -0000 1.16.4.8 +++ squid3/src/HttpRequest.cc 30 Sep 2005 20:58:11 -0000 1.16.4.9 @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.cc,v 1.16.4.8 2005/09/29 22:56:59 dwsquid Exp $ + * $Id: HttpRequest.cc,v 1.16.4.9 2005/09/30 20:58:11 dwsquid Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -381,7 +381,7 @@ * along with this request */ bool -HttpRequest::expectingBody(method_t unused, ssize_t& theSize) +HttpRequest::expectingBody(method_t unused, ssize_t& theSize) const { bool expectBody = false; Index: squid3/src/HttpRequest.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpRequest.h,v retrieving revision 1.13.4.6 retrieving revision 1.13.4.7 diff -u -r1.13.4.6 -r1.13.4.7 --- squid3/src/HttpRequest.h 29 Sep 2005 22:56:59 -0000 1.13.4.6 +++ squid3/src/HttpRequest.h 30 Sep 2005 20:58:11 -0000 1.13.4.7 @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.h,v 1.13.4.6 2005/09/29 22:56:59 dwsquid Exp $ + * $Id: HttpRequest.h,v 1.13.4.7 2005/09/30 20:58:11 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -97,7 +97,7 @@ public: bool parseFirstLine(const char *start, const char *end); int parseHeader(const char *parse_start); - virtual bool expectingBody(method_t unused, ssize_t&); + virtual bool expectingBody(method_t unused, ssize_t&) const; private: const char *packableURI(bool full_uri) const; Index: squid3/src/ICAPAnchor.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPAnchor.cc,v retrieving revision 1.1.2.29 retrieving revision 1.1.2.30 diff -u -r1.1.2.29 -r1.1.2.30 --- squid3/src/ICAPAnchor.cc 29 Sep 2005 18:00:44 -0000 1.1.2.29 +++ squid3/src/ICAPAnchor.cc 30 Sep 2005 20:58:11 -0000 1.1.2.30 @@ -19,7 +19,6 @@ ICAPAnchor::ICAPAnchor(ICAPServiceRep::Pointer aService): service(aService), httpState(NULL), virgin(NULL), adapted(NULL) { debug(93,5)("ICAPAnchor constructed, this=%p\n", this); - debug(0,0)("ICAPAnchor constructed, service=%p\n", service.getRaw()); } ICAPAnchor::~ICAPAnchor() @@ -34,8 +33,6 @@ if (adapted != NULL) freeAdapted(); - debug(0,0)("NULLing ICAPAnchor:service\n"); - service = NULL; } @@ -147,6 +144,9 @@ assert(reply); // check that ICAP xaction created the right object httpState->takeAdaptedHeaders(reply); + assert(reply == adapted->data->header); + adapted->data->header = NULL; + noteSourceProgress(p); } @@ -228,7 +228,19 @@ void ICAPAnchor::freeAdapted() { - adapted->data->header = NULL; // we don't own it + /* + * Note on adapted->data->header. ICAPXaction-side created it + * but gave control of it to us. Normally we give it to + * HttpStateData::takeAdaptedHeader. If not, we have to + * make sure it gets deleted; + */ + + if (adapted->data->header != NULL) { + debug(93,3)("hey, adapted->data->header is still set!\n"); + delete adapted->data->header; + adapted->data->header = NULL; + } + leakTouch(adapted.getRaw(), leaky); adapted = NULL; // refcounted } Index: squid3/src/ICAPConfig.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPConfig.cc,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- squid3/src/ICAPConfig.cc 29 Sep 2005 18:00:44 -0000 1.1.2.4 +++ squid3/src/ICAPConfig.cc 30 Sep 2005 20:58:11 -0000 1.1.2.5 @@ -1,6 +1,6 @@ /* - * $Id: ICAPConfig.cc,v 1.1.2.4 2005/09/29 18:00:44 dwsquid Exp $ + * $Id: ICAPConfig.cc,v 1.1.2.5 2005/09/30 20:58:11 dwsquid Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -135,7 +135,7 @@ void ICAPAccessCheck::check() { - debug(0,0)("ICAPAccessCheck::check\n"); + debug(93,3)("ICAPAccessCheck::check\n"); Vector::iterator i; for (i = TheICAPConfig.services.begin(); i != TheICAPConfig.services.end(); ++i) { @@ -161,7 +161,7 @@ void ICAPAccessCheck::ICAPAccessCheckCallbackWrapper(void *data) { - debug(0,0)("ICAPAccessCheckCallbackWrapper\n"); + debug(93,3)("ICAPAccessCheckCallbackWrapper\n"); ICAPAccessCheck *ac = (ICAPAccessCheck*)data; ac->do_callback(); } @@ -169,7 +169,7 @@ void ICAPAccessCheck::do_callback() { - debug(0,0)("ICAPAccessCheck::do_callback\n"); + debug(93,3)("ICAPAccessCheck::do_callback\n"); callback(match, callback_data); match = NULL; } Index: squid3/src/ICAPXaction.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPXaction.cc,v retrieving revision 1.1.2.35 retrieving revision 1.1.2.36 diff -u -r1.1.2.35 -r1.1.2.36 --- squid3/src/ICAPXaction.cc 29 Sep 2005 21:39:42 -0000 1.1.2.35 +++ squid3/src/ICAPXaction.cc 30 Sep 2005 20:58:11 -0000 1.1.2.36 @@ -188,7 +188,7 @@ &ICAPXaction_noteCommTimeout, this); closer = &ICAPXaction_noteCommClose; comm_add_close_handler(connection, closer, this); - debug(0,0)("ICAPXaction::openConnection() to %s %d\n", service->host.buf(), service->port); + debug(93,3)("ICAPXaction::openConnection() to %s %d\n", service->host.buf(), service->port); commConnectStart(connection, service->host.buf(), service->port, &ICAPXaction_noteCommConnected, this); } @@ -642,6 +642,13 @@ else adapted->source = NULL; + /* + * Note on adapted->data->header: + * we created the header, but allow the other side (ICAPAnchor) + * to take control of it. We won't touch it here and instead + * rely on the Anchor-side to make sure it is properly + * freed. + */ adapted = NULL; // refcounted state.doneSending = true; @@ -801,8 +808,6 @@ */ bool ICAPXaction::expectVirginBody() const { - if (virgin->data->body->contentSize()) // XXX bug - body may come later - return true; - - return false; + ssize_t unused; + return virgin->data->header->expectingBody(virgin->data->cause->method, unused); } Index: squid3/src/http.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.cc,v retrieving revision 1.49.2.37 retrieving revision 1.49.2.38 diff -u -r1.49.2.37 -r1.49.2.38 --- squid3/src/http.cc 30 Sep 2005 16:26:08 -0000 1.49.2.37 +++ squid3/src/http.cc 30 Sep 2005 20:58:11 -0000 1.49.2.38 @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.49.2.37 2005/09/30 16:26:08 dwsquid Exp $ + * $Id: http.cc,v 1.49.2.38 2005/09/30 20:58:11 dwsquid Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -1094,16 +1094,15 @@ } /* - * Store reply body data to StoreEntry or ICAP or ...? + * Call this when there is data from the origin server + * which should be sent to either StoreEntry, or to ICAP... */ void HttpStateData::writeReplyBody(const char *data, int len) { - debug(0,0)("HttpStateData::writeReplyBody() called\n"); #if ICAP_CLIENT if (icap) { - debug(0,0)("HttpStateData::writeReplyBody sending %d bytes to ICAP\n", len); icap->sendMoreData (StoreIOBuffer(len, 0, (char*)data)); return; } @@ -1125,8 +1124,6 @@ void HttpStateData::processReplyBody() { - debug(0,0)("HttpStateData::processReplyBody() called\n"); - if (!flags.headers_parsed) { flags.do_next_read = 1; maybeReadData();