]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Use InstanceId for async job and calls identification.
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 4 Oct 2010 14:52:38 +0000 (08:52 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 4 Oct 2010 14:52:38 +0000 (08:52 -0600)
Side-effect: removes inconsistent prefixes for job debugging: ecapxN, icapxN,
asyncN are now all jobN, simplifying searching and processing debugging logs.

src/adaptation/ecap/XactionRep.cc
src/adaptation/icap/Xaction.cc
src/base/AsyncCall.cc
src/base/AsyncCall.h
src/base/AsyncJob.cc
src/base/AsyncJob.h

index 8a0251733627568571cd1c7497e0764299b96a77..95f2ae53dc7be10a0eeb054876792a232db1af38 100644 (file)
@@ -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();
 
index 7bdf707c07b3e82486dee0e8539f3f3cc1813dd0..14fedfabaf94180c5c12f96c68fff4f40bcb90cd 100644 (file)
@@ -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();
 
index 9bca17efe87bc72c149fd1fedda0d2c14ceaf472..8b241f34613103b650c18ecc74a10a5b9964f8d1 100644 (file)
@@ -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;
 }
index d4df9f64414ed5589fbf6479abeafa0d7b20923e..01066ca2ce3b4d05af23c468103a47efdd60d4b2 100644 (file)
@@ -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<AsyncCall> 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
index 215fd842fc1dfad4691fde2c9daf42c18483f169..9c147be56f57e6ed9aa0701c4f30316c755fc066 100644 (file)
@@ -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();
index df0bf3ca5414079e78496250c613e2cf44c6c052..ebbb70df75ed2db140915249251b25e5ac109e7f 100644 (file)
@@ -6,6 +6,7 @@
 #define SQUID_ASYNC_JOB_H
 
 #include "base/AsyncCall.h"
+#include "base/InstanceId.h"
 
 template <class Cbc>
 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<AsyncJob> id; ///< job identifier
 };
 
 #endif /* SQUID_ASYNC_JOB_H */