From: Alex Rousskov Date: Mon, 4 Oct 2010 14:52:38 +0000 (-0600) Subject: Use InstanceId for async job and calls identification. X-Git-Tag: take1~208 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=52ed047a82bb543fda92591d359d17840de4412d;p=thirdparty%2Fsquid.git Use InstanceId for async job and calls identification. Side-effect: removes inconsistent prefixes for job debugging: ecapxN, icapxN, asyncN are now all jobN, simplifying searching and processing debugging logs. --- diff --git a/src/adaptation/ecap/XactionRep.cc b/src/adaptation/ecap/XactionRep.cc index 8a02517336..95f2ae53dc 100644 --- a/src/adaptation/ecap/XactionRep.cc +++ b/src/adaptation/ecap/XactionRep.cc @@ -446,7 +446,7 @@ Adaptation::Ecap::XactionRep::status() const buf.append(" A.", 3); } - buf.Printf(" ecapx%d]", id); + buf.Printf(" %s%u]", id.Prefix, id.value); buf.terminate(); diff --git a/src/adaptation/icap/Xaction.cc b/src/adaptation/icap/Xaction.cc index 7bdf707c07..14fedfabaf 100644 --- a/src/adaptation/icap/Xaction.cc +++ b/src/adaptation/icap/Xaction.cc @@ -538,7 +538,7 @@ const char *Adaptation::Icap::Xaction::status() const buf.append("/", 1); fillDoneStatus(buf); - buf.Printf(" icapx%d]", id); + buf.Printf(" %s%u]", id.Prefix, id.value); buf.terminate(); diff --git a/src/base/AsyncCall.cc b/src/base/AsyncCall.cc index 9bca17efe8..8b241f3461 100644 --- a/src/base/AsyncCall.cc +++ b/src/base/AsyncCall.cc @@ -7,17 +7,17 @@ #include "base/AsyncCallQueue.h" #include "cbdata.h" -unsigned int AsyncCall::TheLastId = 0; +InstanceIdDefinitions(AsyncCall, "call"); /* AsyncCall */ AsyncCall::AsyncCall(int aDebugSection, int aDebugLevel, const char *aName): name(aName), debugSection(aDebugSection), - debugLevel(aDebugLevel), id(++TheLastId), theNext(0), isCanceled(NULL) + debugLevel(aDebugLevel), theNext(0), isCanceled(NULL) { debugs(debugSection, debugLevel, "The AsyncCall " << name << " constructed, this=" << this << - " [call" << id << ']'); + " [" << id << ']'); } AsyncCall::~AsyncCall() @@ -29,7 +29,7 @@ void AsyncCall::make() { debugs(debugSection, debugLevel, HERE << "make call " << name << - " [call"<< id << ']'); + " [" << id << ']'); if (canFire()) { fire(); return; @@ -39,7 +39,7 @@ AsyncCall::make() isCanceled = "unknown reason"; debugs(debugSection, debugLevel, HERE << "will not call " << name << - " [call"<< id << ']' << " because of " << isCanceled); + " [" << id << ']' << " because of " << isCanceled); } bool @@ -47,7 +47,7 @@ AsyncCall::cancel(const char *reason) { if (isCanceled) debugs(debugSection, debugLevel, HERE << "will not call " << name << - " [call"<< id << ']' << " also because " << reason); + " [" << id << ']' << " also because " << reason); isCanceled = reason; return false; } @@ -73,7 +73,7 @@ bool ScheduleCall(const char *fileName, int fileLine, AsyncCall::Pointer &call) { debugs(call->debugSection, call->debugLevel, fileName << "(" << fileLine << - ") will call " << *call << " [call"<< call->id << ']' ); + ") will call " << *call << " [" << call->id << ']' ); AsyncCallQueue::Instance().schedule(call); return true; } diff --git a/src/base/AsyncCall.h b/src/base/AsyncCall.h index d4df9f6441..01066ca2ce 100644 --- a/src/base/AsyncCall.h +++ b/src/base/AsyncCall.h @@ -6,6 +6,7 @@ #define SQUID_ASYNCCALL_H //#include "cbdata.h" +#include "base/InstanceId.h" #include "event.h" //#include "TextException.h" @@ -69,7 +70,7 @@ public: const char *const name; const int debugSection; const int debugLevel; - const unsigned int id; + const InstanceId id; protected: virtual bool canFire(); @@ -80,7 +81,6 @@ protected: private: const char *isCanceled; // set to the cancelation reason by cancel() - static unsigned int TheLastId; }; inline diff --git a/src/base/AsyncJob.cc b/src/base/AsyncJob.cc index 215fd842fc..9c147be56f 100644 --- a/src/base/AsyncJob.cc +++ b/src/base/AsyncJob.cc @@ -10,8 +10,7 @@ #include "cbdata.h" #include "MemBuf.h" - -unsigned int AsyncJob::TheLastId = 0; +InstanceIdDefinitions(AsyncJob, "job"); AsyncJob::Pointer AsyncJob::Start(AsyncJob *j) { @@ -20,16 +19,16 @@ AsyncJob::Pointer AsyncJob::Start(AsyncJob *j) return job; } -AsyncJob::AsyncJob(const char *aTypeName): typeName(aTypeName), inCall(NULL), id(++TheLastId) +AsyncJob::AsyncJob(const char *aTypeName): typeName(aTypeName), inCall(NULL) { debugs(93,5, "AsyncJob constructed, this=" << this << - " type=" << typeName << " [job" << id << ']'); + " type=" << typeName << " [" << id << ']'); } AsyncJob::~AsyncJob() { debugs(93,5, "AsyncJob destructed, this=" << this << - " type=" << typeName << " [job" << id << ']'); + " type=" << typeName << " [" << id << ']'); } void AsyncJob::start() @@ -156,7 +155,7 @@ const char *AsyncJob::status() const buf.Printf("Stopped, reason:"); buf.Printf("%s",stopReason); } - buf.Printf(" job%d]", id); + buf.Printf(" %s%u]", id.Prefix, id.value); buf.terminate(); return buf.content(); diff --git a/src/base/AsyncJob.h b/src/base/AsyncJob.h index df0bf3ca54..ebbb70df75 100644 --- a/src/base/AsyncJob.h +++ b/src/base/AsyncJob.h @@ -6,6 +6,7 @@ #define SQUID_ASYNC_JOB_H #include "base/AsyncCall.h" +#include "base/InstanceId.h" template class CbcPointer; @@ -63,10 +64,7 @@ protected: const char *stopReason; ///< reason for forcing done() to be true const char *typeName; ///< kid (leaf) class name, for debugging AsyncCall::Pointer inCall; ///< the asynchronous call being handled, if any - const unsigned int id; ///< unique ID across all strand jobs, unless wraps - -private: - static unsigned int TheLastId; ///< makes job IDs unique until it wraps + const InstanceId id; ///< job identifier }; #endif /* SQUID_ASYNC_JOB_H */