--------------------- PatchSet 1568 Date: 2005/08/23 15:36:54 Author: rousskov Branch: squid3-icap Tag: (none) Log: - When abort or finish messages are sent, set the source to NULL under the assumption that finished or aborted source does not want to receive anything. Members: src/MsgPipe.cc:1.1.2.4->1.1.2.5 src/MsgPipe.h:1.1.2.3->1.1.2.4 Index: squid3/src/MsgPipe.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/MsgPipe.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/MsgPipe.cc 20 Aug 2005 06:17:25 -0000 1.1.2.4 +++ squid3/src/MsgPipe.cc 23 Aug 2005 15:36:54 -0000 1.1.2.5 @@ -11,11 +11,7 @@ static \ void MsgPipe_send ## callName(void *p) { \ MsgPipe *pipe = static_cast(p); \ - debugs(0,0, "MsgPipe " << pipe->name << "(" << pipe << ") does " << \ - "send" << #callName << " to " << pipe->destination << \ - "; data: " << pipe->data << \ - "; source: " << pipe->source << "; sink: " << pipe->sink); \ - if (pipe->destination && cbdataReferenceValid(pipe->destination)) \ + if (pipe && pipe->canSend(pipe->destination, #callName, false)) \ pipe->destination->note##callName(pipe); \ } @@ -34,38 +30,52 @@ void MsgPipe::sendSourceStart() { - sendLater("sendSourceStart", &MsgPipe_sendSourceStart, sink); + sendLater("SourceStart", &MsgPipe_sendSourceStart, sink); } void MsgPipe::sendSourceProgress() { - sendLater("sendSourceProgress", &MsgPipe_sendSourceProgress, sink); + sendLater("SourceProgress", &MsgPipe_sendSourceProgress, sink); } void MsgPipe::sendSourceFinish() { - sendLater("sendSourceFinish", &MsgPipe_sendSourceFinish, sink); + sendLater("SourceFinish", &MsgPipe_sendSourceFinish, sink); + source = NULL; } void MsgPipe::sendSourceAbort() { - sendLater("sendSourceAbort", &MsgPipe_sendSourceAbort, sink); + sendLater("SourceAbort", &MsgPipe_sendSourceAbort, sink); + source = NULL; } void MsgPipe::sendSinkNeed() { - sendLater("sendSinkNeed", &MsgPipe_sendSinkNeed, source); + sendLater("SinkNeed", &MsgPipe_sendSinkNeed, source); } void MsgPipe::sendSinkAbort() { - sendLater("sendSinkAbort", &MsgPipe_sendSinkAbort, source); + sendLater("SinkAbort", &MsgPipe_sendSinkAbort, source); + sink = NULL; } -void MsgPipe::sendLater(const char *callName, EVH * handler, void *destination) { - debugs(0,0, "MsgPipe " << name << "(" << this << ") will " << callName << - " to " << destination << "; data: " << data << - "; source: " << source << "; sink " << sink); - eventAdd(callName, handler, this, 0, true); +void MsgPipe::sendLater(const char *callName, EVH * handler, MsgPipeEnd *destination) { + if (canSend(destination, callName, true)) + eventAdd(callName, handler, this, 0, true); +} + +bool MsgPipe::canSend(MsgPipeEnd *destination, const char *callName, bool future) { + const bool res = destination != NULL; + const char *verb = future ? + (res ? "will send " : "wont send ") : + (res ? "sends " : "ignores "); + debugs(0,0, "MsgPipe " << name << "(" << this << ") " << + verb << callName << " to the " << + (destination ? destination->kind() : "destination") << "(" << + destination << "); " << + "data: " << data << "; source: " << source << "; sink " << sink); + return res; } Index: squid3/src/MsgPipe.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/MsgPipe.h,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- squid3/src/MsgPipe.h 20 Aug 2005 06:17:25 -0000 1.1.2.3 +++ squid3/src/MsgPipe.h 23 Aug 2005 15:36:54 -0000 1.1.2.4 @@ -1,6 +1,6 @@ /* - * $Id: MsgPipe.h,v 1.1.2.3 2005/08/20 06:17:25 rousskov Exp $ + * $Id: MsgPipe.h,v 1.1.2.4 2005/08/23 15:36:54 rousskov Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -42,6 +42,7 @@ // recepient's and sender's note*() methods. class MsgPipeData; +class MsgPipeEnd; class MsgPipeSource; class MsgPipeSink; @@ -60,6 +61,8 @@ void sendSinkNeed(); void sendSinkAbort(); + // private method exposed for the event handler only + bool canSend(MsgPipeEnd *destination, const char *callName, bool future); public: const char *name; // unmanaged pointer used for debugging only @@ -68,7 +71,7 @@ MsgPipeSink *sink; private: - void sendLater(const char *callName, EVH * handler, void *destination); + void sendLater(const char *callName, EVH * handler, MsgPipeEnd *destination); CBDATA_CLASS2(MsgPipe); };