--------------------- PatchSet 2100 Date: 2005/11/03 00:28:58 Author: dwsquid Branch: squid3-icap Tag: (none) Log: In ICAPOptXact::parseResponse(), the HttpReply must be allocted from the heap because HttpReply has no desctructor to free memory and clean up. Because of this, I also changed related functions to take a HttpMsg*, instead of a reference. Members: src/ICAPOptXact.cc:1.1.2.5->1.1.2.6 src/ICAPOptions.cc:1.1.2.6->1.1.2.7 src/ICAPOptions.h:1.1.2.5->1.1.2.6 src/ICAPXaction.cc:1.1.2.51->1.1.2.52 src/ICAPXaction.h:1.1.2.27->1.1.2.28 Index: squid3/src/ICAPOptXact.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPOptXact.cc,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/ICAPOptXact.cc 17 Oct 2005 22:58:29 -0000 1.1.2.5 +++ squid3/src/ICAPOptXact.cc 3 Nov 2005 00:28:58 -0000 1.1.2.6 @@ -94,15 +94,18 @@ bool ICAPOptXact::parseResponse() { - HttpReply r; - r.protoPrefix = "ICAP/"; // TODO: make an IcapReply class? + HttpReply *r = httpReplyCreate(); + r->protoPrefix = "ICAP/"; // TODO: make an IcapReply class? - if (!parseHttpMsg(r)) + if (!parseHttpMsg(r)) { + httpReplyDestroy(r); return false; + } options = new ICAPOptions; options->configure(r); + httpReplyDestroy(r); return true; } Index: squid3/src/ICAPOptions.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPOptions.cc,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- squid3/src/ICAPOptions.cc 17 Oct 2005 23:19:48 -0000 1.1.2.6 +++ squid3/src/ICAPOptions.cc 3 Nov 2005 00:28:58 -0000 1.1.2.7 @@ -107,13 +107,13 @@ return ttl >= 0 ? timestamp + ttl : -1; } -void ICAPOptions::configure(const HttpReply &reply) +void ICAPOptions::configure(const HttpReply *reply) { error = NULL; // reset initial "unconfigured" value (or an old error?) - const HttpHeader *h = &reply.header; + const HttpHeader *h = &reply->header; - if (reply.sline.status != 200) + if (reply->sline.status != 200) error = "unsupported status code of OPTIONS response"; // Methods Index: squid3/src/ICAPOptions.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPOptions.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/ICAPOptions.h 17 Oct 2005 23:19:48 -0000 1.1.2.5 +++ squid3/src/ICAPOptions.h 3 Nov 2005 00:28:58 -0000 1.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: ICAPOptions.h,v 1.1.2.5 2005/10/17 23:19:48 rousskov Exp $ + * $Id: ICAPOptions.h,v 1.1.2.6 2005/11/03 00:28:58 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -52,7 +52,7 @@ ICAPOptions(); ~ICAPOptions(); - void configure(const HttpReply &reply); + void configure(const HttpReply *reply); bool valid() const; bool fresh() const; Index: squid3/src/ICAPXaction.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPXaction.cc,v retrieving revision 1.1.2.51 retrieving revision 1.1.2.52 diff -u -r1.1.2.51 -r1.1.2.52 --- squid3/src/ICAPXaction.cc 17 Oct 2005 22:58:29 -0000 1.1.2.51 +++ squid3/src/ICAPXaction.cc 3 Nov 2005 00:28:58 -0000 1.1.2.52 @@ -259,21 +259,21 @@ } } -bool ICAPXaction::parseHttpMsg(HttpMsg &msg) +bool ICAPXaction::parseHttpMsg(HttpMsg *msg) { debugs(93, 5, "have " << readBuf.contentSize() << " head bytes to parse"); http_status error = HTTP_STATUS_NONE; - const bool parsed = msg.parse(&readBuf, commEof, &error); + const bool parsed = msg->parse(&readBuf, commEof, &error); Must(parsed || !error); // success or need more data if (!parsed) { // need more data Must(mayReadMore()); - msg.reset(); + msg->reset(); return false; } - readBuf.consume(msg.hdr_sz); + readBuf.consume(msg->hdr_sz); return true; } Index: squid3/src/ICAPXaction.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPXaction.h,v retrieving revision 1.1.2.27 retrieving revision 1.1.2.28 diff -u -r1.1.2.27 -r1.1.2.28 --- squid3/src/ICAPXaction.h 17 Oct 2005 22:58:29 -0000 1.1.2.27 +++ squid3/src/ICAPXaction.h 3 Nov 2005 00:28:58 -0000 1.1.2.28 @@ -1,6 +1,6 @@ /* - * $Id: ICAPXaction.h,v 1.1.2.27 2005/10/17 22:58:29 rousskov Exp $ + * $Id: ICAPXaction.h,v 1.1.2.28 2005/11/03 00:28:58 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -83,7 +83,7 @@ void cancelRead(); - bool parseHttpMsg(HttpMsg &msg); // true=success; false=needMore; throw=err + bool parseHttpMsg(HttpMsg *msg); // true=success; false=needMore; throw=err bool mayReadMore() const; virtual bool doneReading() const;