--------------------- PatchSet 3852 Date: 2006/10/09 17:32:00 Author: rousskov Branch: squid3-icap Tag: (none) Log: - Close or recycle the ICAP connection when it is no longer needed, even if the transaction is still going on. This optimization is useful when handling a large HTTP message and receiving an ICAP 204 "No Content" response. The 204 response allows us to stop talking to the ICAP server much sooner than we can stop echoing the large HTTP message back to the ICAPVector. Members: src/ICAP/ICAPModXact.h:1.1.2.5->1.1.2.6 src/ICAP/ICAPXaction.cc:1.1.2.8->1.1.2.9 src/ICAP/ICAPXaction.h:1.1.2.4->1.1.2.5 Index: squid3/src/ICAP/ICAPModXact.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPModXact.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/ICAP/ICAPModXact.h 3 Oct 2006 19:53:07 -0000 1.1.2.5 +++ squid3/src/ICAP/ICAPModXact.h 9 Oct 2006 17:32:00 -0000 1.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: ICAPModXact.h,v 1.1.2.5 2006/10/03 19:53:07 rousskov Exp $ + * $Id: ICAPModXact.h,v 1.1.2.6 2006/10/09 17:32:00 rousskov Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -167,6 +167,7 @@ void startReading(); void readMore(); virtual bool doneReading() const { return commEof || state.doneParsing(); } + virtual bool doneWriting() const { return state.doneWriting(); } size_t claimSize(const MemBufClaim &claim) const; const char *claimContent(const MemBufClaim &claim) const; Index: squid3/src/ICAP/ICAPXaction.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPXaction.cc,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -r1.1.2.8 -r1.1.2.9 --- squid3/src/ICAP/ICAPXaction.cc 7 Oct 2006 05:19:40 -0000 1.1.2.8 +++ squid3/src/ICAP/ICAPXaction.cc 9 Oct 2006 17:32:00 -0000 1.1.2.9 @@ -365,6 +365,18 @@ return commEof; } +bool ICAPXaction::doneWriting() const +{ + return !writer; +} + +bool ICAPXaction::doneWithIo() const +{ + return connection >= 0 && // or we could still be waiting to open it + !connector && !reader && !writer && // fast checks, some redundant + doneReading() && doneWriting(); +} + void ICAPXaction::mustStop(const char *aReason) { Must(inCall); // otherwise nobody will call doStop() @@ -430,6 +442,10 @@ status()); doStop(); // may delete us return; + } else + if (doneWithIo()) { + debugs(93, 5, HERE << typeName << " done with I/O " << status()); + closeConnection(); } debugs(93, 6, typeName << "::" << inCall << " ended " << status()); Index: squid3/src/ICAP/ICAPXaction.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPXaction.h,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/ICAP/ICAPXaction.h 6 Oct 2006 17:53:48 -0000 1.1.2.4 +++ squid3/src/ICAP/ICAPXaction.h 9 Oct 2006 17:32:00 -0000 1.1.2.5 @@ -1,6 +1,6 @@ /* - * $Id: ICAPXaction.h,v 1.1.2.4 2006/10/06 17:53:48 rousskov Exp $ + * $Id: ICAPXaction.h,v 1.1.2.5 2006/10/09 17:32:00 rousskov Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -88,6 +88,8 @@ bool parseHttpMsg(HttpMsg *msg); // true=success; false=needMore; throw=err bool mayReadMore() const; virtual bool doneReading() const; + virtual bool doneWriting() const; + bool doneWithIo() const; bool done() const; virtual bool doneAll() const;