--------------------- PatchSet 6124 Date: 2007/11/13 22:32:11 Author: chtsanti Branch: async-calls Tag: (none) Log: -The methods AsyncJob::start AsyncJob::doneAll AsyncJob::swanSong and AsyncJob: :status are not pure any more. -Implement the AsyncJob::status with a similar way the ICAPXaction::status is i mplemented. Moving the TheLastId/id mechanism for objects id generation from the ICAXaction to the AsyncJob class -Implement the doneAll method for AsyncJob derived classes Members: src/AsyncCall.cc:1.3.22.3->1.3.22.4 src/Server.h:1.10.4.3->1.10.4.4 src/client_side.h:1.22.4.2->1.22.4.3 src/client_side_request.h:1.30.4.3->1.30.4.4 src/ICAP/AsyncJob.cc:1.3.4.5->1.3.4.6 src/ICAP/AsyncJob.h:1.3.14.5->1.3.14.6 src/ICAP/ICAPServiceRep.h:1.11.4.1->1.11.4.2 src/ICAP/ICAPXaction.cc:1.22.4.1->1.22.4.2 src/ICAP/ICAPXaction.h:1.11->1.11.14.1 Index: squid3/src/AsyncCall.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/AsyncCall.cc,v retrieving revision 1.3.22.3 retrieving revision 1.3.22.4 diff -u -r1.3.22.3 -r1.3.22.4 --- squid3/src/AsyncCall.cc 13 Nov 2007 17:40:34 -0000 1.3.22.3 +++ squid3/src/AsyncCall.cc 13 Nov 2007 22:32:11 -0000 1.3.22.4 @@ -89,10 +89,7 @@ Tester():AsyncJob("Tester"){} virtual ~Tester() {} - virtual void start(){}; virtual bool doneAll() const{return true;}; // return true when done - virtual void swanSong(){}; // perform internal cleanup - virtual const char *status() const {return NULL;}; // for debugging virtual void method0() { debugs(0,0, HERE << "METHOD0()"); } virtual void method1(int arg1) { debugs(0,0, HERE << "METHOD1(" << arg1 << ")"); } Index: squid3/src/Server.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Server.h,v retrieving revision 1.10.4.3 retrieving revision 1.10.4.4 diff -u -r1.10.4.3 -r1.10.4.4 --- squid3/src/Server.h 23 Oct 2007 22:46:42 -0000 1.10.4.3 +++ squid3/src/Server.h 13 Nov 2007 22:32:11 -0000 1.10.4.4 @@ -1,6 +1,6 @@ /* - * $Id: Server.h,v 1.10.4.3 2007/10/23 22:46:42 chtsanti Exp $ + * $Id: Server.h,v 1.10.4.4 2007/11/13 22:32:11 chtsanti Exp $ * * AUTHOR: Duane Wessels * @@ -104,10 +104,9 @@ virtual void processReplyBody() = 0; //AsyncJob virtual methods - virtual void start(){/*Just Do nothing*/} - virtual bool doneAll() const { assert(false); return false;} - virtual void swanSong(){/*Just Do nothing*/} - virtual const char* status() const {return "Maybe OK!";} + virtual bool doneAll() const { return ICAPInitiator::doneAll() && + BodyProducer::doneAll() && + BodyConsumer::doneAll() && false;} public: // should be protected void serverComplete(); // call when no server communication is expected Index: squid3/src/client_side.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side.h,v retrieving revision 1.22.4.2 retrieving revision 1.22.4.3 diff -u -r1.22.4.2 -r1.22.4.3 --- squid3/src/client_side.h 23 Oct 2007 22:17:06 -0000 1.22.4.2 +++ squid3/src/client_side.h 13 Nov 2007 22:32:11 -0000 1.22.4.3 @@ -1,6 +1,6 @@ /* - * $Id: client_side.h,v 1.22.4.2 2007/10/23 22:17:06 chtsanti Exp $ + * $Id: client_side.h,v 1.22.4.3 2007/11/13 22:32:11 chtsanti Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -212,10 +212,7 @@ void handleRequestBodyData(); //AsyncJob virtual classes - virtual void start(){/*Just Do nothing*/} - virtual bool doneAll() const { assert(false); return false;} - virtual void swanSong(){/*Just Do nothing*/} - virtual const char* status() const {return "Maybe OK!";} + virtual bool doneAll() const { return BodyProducer::doneAll() && false;} private: CBDATA_CLASS2(ConnStateData); Index: squid3/src/client_side_request.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side_request.h,v retrieving revision 1.30.4.3 retrieving revision 1.30.4.4 diff -u -r1.30.4.3 -r1.30.4.4 --- squid3/src/client_side_request.h 25 Oct 2007 16:41:20 -0000 1.30.4.3 +++ squid3/src/client_side_request.h 13 Nov 2007 22:32:11 -0000 1.30.4.4 @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.h,v 1.30.4.3 2007/10/25 16:41:20 chtsanti Exp $ + * $Id: client_side_request.h,v 1.30.4.4 2007/11/13 22:32:11 chtsanti Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -155,10 +155,8 @@ void doCallouts(); //AsyncJob virtual methods - virtual void start(){/*Just Do nothing*/} - virtual bool doneAll() const { assert(false); return false;} - virtual void swanSong(){/*Just Do nothing*/} - virtual const char* status() const {return "Maybe OK!";} + virtual bool doneAll() const { return ICAPInitiator::doneAll() && + BodyConsumer::doneAll() && false;} private: CBDATA_CLASS(ClientHttpRequest); Index: squid3/src/ICAP/AsyncJob.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/AsyncJob.cc,v retrieving revision 1.3.4.5 retrieving revision 1.3.4.6 diff -u -r1.3.4.5 -r1.3.4.6 --- squid3/src/ICAP/AsyncJob.cc 6 Nov 2007 18:37:01 -0000 1.3.4.5 +++ squid3/src/ICAP/AsyncJob.cc 13 Nov 2007 22:32:12 -0000 1.3.4.6 @@ -4,6 +4,7 @@ #include "squid.h" #include "cbdata.h" +#include "MemBuf.h" #include "TextException.h" #include "AsyncJob.h" #include "AsyncCall.h" @@ -49,6 +50,7 @@ } +unsigned int AsyncJob::TheLastId = 0; AsyncJob *AsyncJob::AsyncStart(AsyncJob *job) { assert(job); @@ -61,8 +63,10 @@ return job; } -AsyncJob::AsyncJob(const char *aTypeName): typeName(aTypeName), inCall(NULL) +AsyncJob::AsyncJob(const char *aTypeName): typeName(aTypeName), inCall(NULL), id(++TheLastId) { + debugs(93,3, "AsyncJob of type " << typeName << " constructed, this=" << this << + " [async" << id << ']'); } AsyncJob::~AsyncJob() @@ -206,3 +210,19 @@ inCall = NULL; } +// returns a temporary string depicting transaction status, for debugging +const char *AsyncJob::status() const +{ + static MemBuf buf; + buf.reset(); + + buf.append(" [", 2); + if (stopReason != NULL){ + buf.Printf("Stopped, reason:"); + buf.Printf(stopReason); + } + buf.Printf(" async%d]", id); + buf.terminate(); + + return buf.content(); +} Index: squid3/src/ICAP/AsyncJob.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/AsyncJob.h,v retrieving revision 1.3.14.5 retrieving revision 1.3.14.6 diff -u -r1.3.14.5 -r1.3.14.6 --- squid3/src/ICAP/AsyncJob.h 6 Nov 2007 18:37:01 -0000 1.3.14.5 +++ squid3/src/ICAP/AsyncJob.h 13 Nov 2007 22:32:12 -0000 1.3.14.6 @@ -1,6 +1,6 @@ /* - * $Id: AsyncJob.h,v 1.3.14.5 2007/11/06 18:37:01 chtsanti Exp $ + * $Id: AsyncJob.h,v 1.3.14.6 2007/11/13 22:32:12 chtsanti Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -101,10 +101,10 @@ bool done() const; // the job is destroyed in callEnd() when done() - virtual void start() = 0; - virtual bool doneAll() const = 0; // return true when done - virtual void swanSong() = 0; // perform internal cleanup - virtual const char *status() const = 0; // for debugging + virtual void start(); + virtual bool doneAll() const; // return true when done + virtual void swanSong() {}; // perform internal cleanup + virtual const char *status() const; // for debugging public: // asynchronous call maintenance @@ -116,6 +116,10 @@ const char *stopReason; // reason for forcing done() to be true const char *typeName; // kid (leaf) class name, for debugging const char *inCall; // name of the asynchronous call being executed, if any + const unsigned int id; + +private: + static unsigned int TheLastId; }; Index: squid3/src/ICAP/ICAPServiceRep.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPServiceRep.h,v retrieving revision 1.11.4.1 retrieving revision 1.11.4.2 diff -u -r1.11.4.1 -r1.11.4.2 --- squid3/src/ICAP/ICAPServiceRep.h 23 Oct 2007 22:42:07 -0000 1.11.4.1 +++ squid3/src/ICAP/ICAPServiceRep.h 13 Nov 2007 22:32:12 -0000 1.11.4.2 @@ -1,6 +1,6 @@ /* - * $Id: ICAPServiceRep.h,v 1.11.4.1 2007/10/23 22:42:07 chtsanti Exp $ + * $Id: ICAPServiceRep.h,v 1.11.4.2 2007/11/13 22:32:12 chtsanti Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -101,9 +101,7 @@ void noteFailure(); // called by transactions to report service failure //AsyncJob virtual methods - virtual void start(){/*Just Do nothing*/} - virtual bool doneAll() const { assert(false); return false;} - virtual void swanSong(){/*Just Do nothing*/} + virtual bool doneAll() const { return ICAPInitiator::doneAll() && false;} public: String key; Index: squid3/src/ICAP/ICAPXaction.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPXaction.cc,v retrieving revision 1.22.4.1 retrieving revision 1.22.4.2 diff -u -r1.22.4.1 -r1.22.4.2 --- squid3/src/ICAP/ICAPXaction.cc 22 Oct 2007 19:26:14 -0000 1.22.4.1 +++ squid3/src/ICAP/ICAPXaction.cc 13 Nov 2007 22:32:12 -0000 1.22.4.2 @@ -13,7 +13,6 @@ static PconnPool *icapPconnPool = new PconnPool("ICAP Servers"); -int ICAPXaction::TheLastId = 0; //CBDATA_CLASS_INIT(ICAPXaction); @@ -63,7 +62,6 @@ ICAPXaction::ICAPXaction(const char *aTypeName, ICAPInitiator *anInitiator, ICAPServiceRep::Pointer &aService): AsyncJob(aTypeName), ICAPInitiate(aTypeName, anInitiator, aService), - id(++TheLastId), connection(-1), commBuf(NULL), commBufSize(0), commEof(false), Index: squid3/src/ICAP/ICAPXaction.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPXaction.h,v retrieving revision 1.11 retrieving revision 1.11.14.1 diff -u -r1.11 -r1.11.14.1 --- squid3/src/ICAP/ICAPXaction.h 19 Jun 2007 21:52:09 -0000 1.11 +++ squid3/src/ICAP/ICAPXaction.h 13 Nov 2007 22:32:12 -0000 1.11.14.1 @@ -1,6 +1,6 @@ /* - * $Id: ICAPXaction.h,v 1.11 2007/06/19 21:52:09 squidadm Exp $ + * $Id: ICAPXaction.h,v 1.11.14.1 2007/11/13 22:32:12 chtsanti Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -111,8 +111,6 @@ virtual void callEnd(); protected: - const int id; // transaction ID for debugging, unique across ICAP xactions - int connection; // FD of the ICAP server connection /* @@ -143,8 +141,6 @@ PF *closer; private: - static int TheLastId; - static void reusedConnection(void *data); //CBDATA_CLASS2(ICAPXaction);