--------------------- PatchSet 6204 Date: 2007/11/29 18:28:49 Author: rousskov Branch: async-calls Tag: (none) Log: I realized that cbdata does not destroy objects when they become unlocked. This means that the Job does not need to lock itself in AsyncStart (the latest code was missing that lock, but that is another story) and unlock itself when it is done(). Now, we simply check that the Job is locked by the async caller. If that paranoid check fails, somebody is using async calls whithout holding a lock on the callee, which is prohibited. Fortunately, new JobCall already locks and unlocks the callee as needed. Members: src/ICAP/AsyncJob.cc:1.3.4.8->1.3.4.9 Index: squid3/src/ICAP/AsyncJob.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/AsyncJob.cc,v retrieving revision 1.3.4.8 retrieving revision 1.3.4.9 diff -u -r1.3.4.8 -r1.3.4.9 --- squid3/src/ICAP/AsyncJob.cc 27 Nov 2007 21:25:13 -0000 1.3.4.8 +++ squid3/src/ICAP/AsyncJob.cc 29 Nov 2007 18:28:49 -0000 1.3.4.9 @@ -35,7 +35,6 @@ void AsyncJob::start() { - Must(cbdataReferenceValid(this->toCbdata())); // locked in AsyncStart } // XXX: temporary code to replace calls to "delete this" in jobs-in-transition. @@ -54,10 +53,6 @@ debugs(93, 5, typeName << " will delete this, reason: " << stopReason); inCall = "FAKE-deleteThis"; - //callEnd will try to do a cbdataReferenceDone because - //normally called after an AsyncStart call which do a cbdataReference - //so we need this hack here - cbdataReference(this->toCbdata()); callEnd(); } @@ -95,6 +90,9 @@ bool AsyncJob::callStart(const char *method) { + // we must be called asynchronously and hence, the caller must lock us + Must(cbdataReferenceValid(toCbdata())); + debugs(93, 5, typeName << "::" << method << " called" << status()); if (inCall) { @@ -112,6 +110,9 @@ void AsyncJob::callException(const TextException &e) { + // we must be called asynchronously and hence, the caller must lock us + Must(cbdataReferenceValid(toCbdata())); + debugs(93, 3, typeName << "::" << inCall << " caught an exception: " << e.message << ' ' << status());