--------------------- PatchSet 3847 Date: 2006/10/07 05:14:53 Author: rousskov Branch: squid3-icap Tag: (none) Log: - Do not tell the owner to finish adaptation until we are done sending virgin data and receiving adapted data. The old code would finish adaptation at the and of the adapted data, which could leave the ICAP transaction forever waiting for remaining virgin data. Members: src/ICAP/ICAPClientVector.cc:1.1.2.2->1.1.2.3 src/ICAP/ICAPClientVector.h:1.1.2.1->1.1.2.2 Index: squid3/src/ICAP/ICAPClientVector.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPClientVector.cc,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid3/src/ICAP/ICAPClientVector.cc 6 Oct 2006 17:53:48 -0000 1.1.2.2 +++ squid3/src/ICAP/ICAPClientVector.cc 7 Oct 2006 05:14:53 -0000 1.1.2.3 @@ -50,7 +50,7 @@ void ICAPClientVector::sendMoreData(StoreIOBuffer buf) { - debug(93,3)("ICAPClientVector::sendMoreData() called\n"); + debug(93,7)("%s::sendMoreData(%p)\n", vPoint, this); //debugs(93,0,HERE << "appending " << buf.length << " bytes"); //debugs(93,0,HERE << "body.contentSize = " << virgin->data->body->contentSize()); //buf.dump(); @@ -75,30 +75,32 @@ // Owner says we have the entire HTTP message void ICAPClientVector::doneSending() { - debug(93,3)("ICAPClientVector::doneSending() called\n"); + debug(93,3)("%s::doneSending(%p)\n", vPoint, this); #if ICAP_ANCHOR_LOOPBACK /* simple assignments are not the right way to do this */ adapted->data->setHeader(virgin->data->header); adapted->data->body = virgin->data->body; noteSourceFinish(adapted); + // checkDoneAdapting() does not support loopback mode return; #else virgin->sendSourceFinish(); + checkDoneAdapting(); // may call the owner back, unfortunately #endif } // Owner tells us to abort void ICAPClientVector::ownerAbort() { - debug(93,3)("ICAPClientVector::ownerAbort() called\n"); + debug(93,3)("%s::ownerAbort(%p)\n", vPoint, this); stop(notifyIcap); } // ICAP client needs more virgin response data void ICAPClientVector::noteSinkNeed(MsgPipe *p) { - debug(93,3)("ICAPClientVector::noteSinkNeed() called\n"); + debug(93,3)("%s::noteSinkNeed(%p)\n", vPoint, this); if (virgin->data->body->potentialSpaceSize()) tellSpaceAvailable(); @@ -107,26 +109,35 @@ // ICAP client aborting void ICAPClientVector::noteSinkAbort(MsgPipe *p) { - debug(93,3)("ICAPClientVector::noteSinkAbort() called\n"); + debug(93,3)("%s::noteSinkAbort(%p)\n", vPoint, this); stop(notifyOwner); // deletes us } // ICAP client is done sending adapted response void ICAPClientVector::noteSourceFinish(MsgPipe *p) { - debug(93,3)("ICAPClientVector::noteSourceFinish() called\n"); - tellDoneAdapting(); // deletes us + debug(93,3)("%s::noteSourceFinish(%p)\n", vPoint, this); + checkDoneAdapting(); // may delete us +} + +void ICAPClientVector::checkDoneAdapting() { + debug(93,5)("%s::checkDoneAdapting(%p): %d & %d\n", vPoint, this, + (int)!virgin->source, (int)!adapted->source); + // done if we are not sending and are not receiving + if (!virgin->source && !adapted->source) + tellDoneAdapting(); // deletes us } // ICAP client is aborting void ICAPClientVector::noteSourceAbort(MsgPipe *p) { - debug(93,3)("ICAPClientVector::noteSourceAbort() called\n"); + debug(93,3)("%s::noteSourceAbort(%p)\n", vPoint, this); stop(notifyOwner); // deletes us } void ICAPClientVector::stop(Notify notify) { + debug(93,3)("%s::stop(%p, %d)\n", vPoint, this, (int)notify); clean(notify, true); } Index: squid3/src/ICAP/ICAPClientVector.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPClientVector.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid3/src/ICAP/ICAPClientVector.h 6 Oct 2006 16:43:03 -0000 1.1.2.1 +++ squid3/src/ICAP/ICAPClientVector.h 7 Oct 2006 05:14:53 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: ICAPClientVector.h,v 1.1.2.1 2006/10/06 16:43:03 rousskov Exp $ + * $Id: ICAPClientVector.h,v 1.1.2.2 2006/10/07 05:14:53 rousskov Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -86,6 +86,9 @@ void startMod(void *anOwner, HttpRequest *cause, HttpMsg *header); void clean(Notify notify, bool cleanAdapted = true); +private: + void checkDoneAdapting(); + public: void *theOwner; const char *vPoint; // unmanaged vectoring point name for debugging