]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Revert rev.14029
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 22 Apr 2015 11:06:20 +0000 (04:06 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 22 Apr 2015 11:06:20 +0000 (04:06 -0700)
src/cbdata.cc

index a92058085db6a80d8c4efc3549b92f4302f107d9..ad3c2e9aa11734f8eec832f2600a56700de0c9cb 100644 (file)
@@ -9,13 +9,14 @@
 /* DEBUG: section 45    Callback Data Registry */
 
 #include "squid.h"
-#include "base/Lock.h"
 #include "cbdata.h"
 #include "Generic.h"
 #include "mem/Pool.h"
 #include "mgr/Registration.h"
 #include "Store.h"
 
+#include <climits>
+
 #if USE_CBDATA_DEBUG
 #include <algorithm>
 #include <vector>
@@ -25,7 +26,7 @@
 #include <map>
 #endif
 
-static uint64_t cbdataCount = 0;
+static int cbdataCount = 0;
 #if USE_CBDATA_DEBUG
 dlink_list cbdataEntries;
 #endif
@@ -56,7 +57,7 @@ public:
  * validate them before issuing the callback, and then free them
  * when finished.
  */
-class cbdata : public Lock
+class cbdata
 {
 #if !WITH_VALGRIND
 public:
@@ -79,7 +80,7 @@ public:
 #endif
     cbdata() :
         valid(0),
-        type(CBDATA_UNKNOWN),
+        locks(0),
 #if USE_CBDATA_DEBUG
         file(NULL),
         line(0),
@@ -90,6 +91,7 @@ public:
     ~cbdata();
 
     int valid;
+    int32_t locks;
     cbdata_type type;
 #if USE_CBDATA_DEBUG
 
@@ -231,7 +233,7 @@ cbdataInternalAlloc(cbdata_type type, const char *file, int line)
 
     c->type = type;
     c->valid = 1;
-    assert(c->LockCount() == 0);
+    c->locks = 0;
     c->cookie = (long) c ^ cbdata::Cookie;
     ++cbdataCount;
 #if USE_CBDATA_DEBUG
@@ -310,8 +312,8 @@ cbdataInternalFree(void *p, const char *file, int line)
     c->addHistory("Free", file, line);
 #endif
 
-    if (c->LockCount()) {
-        debugs(45, 9, p << " has " << c->LockCount() << " locks, not freeing");
+    if (c->locks) {
+        debugs(45, 9, p << " has " << c->locks << " locks, not freeing");
         return NULL;
     }
 
@@ -338,15 +340,17 @@ cbdataInternalLock(const void *p)
 #endif
 
 #if USE_CBDATA_DEBUG
-    debugs(45, 3, p << "=" << (c ? c->LockCount() + 1 : -1) << " " << file << ":" << line);
+    debugs(45, 3, p << "=" << (c ? c->locks + 1 : -1) << " " << file << ":" << line);
     c->addHistory("Reference", file, line);
 #else
-    debugs(45, 9, p << "=" << (c ? c->LockCount() + 1 : -1));
+    debugs(45, 9, p << "=" << (c ? c->locks + 1 : -1));
 #endif
 
     c->check(__LINE__);
 
-    c->lock();
+    assert(c->locks < INT_MAX);
+
+    ++ c->locks;
 }
 
 void
@@ -368,19 +372,21 @@ cbdataInternalUnlock(const void *p)
 #endif
 
 #if USE_CBDATA_DEBUG
-    debugs(45, 3, p << "=" << (c ? c->LockCount() - 1 : -1) << " " << file << ":" << line);
+    debugs(45, 3, p << "=" << (c ? c->locks - 1 : -1) << " " << file << ":" << line);
     c->addHistory("Dereference", file, line);
 #else
-    debugs(45, 9, p << "=" << (c ? c->LockCount() - 1 : -1));
+    debugs(45, 9, p << "=" << (c ? c->locks - 1 : -1));
 #endif
 
     c->check(__LINE__);
 
     assert(c != NULL);
 
-    c->unlock();
+    assert(c->locks > 0);
+
+    -- c->locks;
 
-    if (c->LockCount() > 0)
+    if (c->locks)
         return;
 
     if (c->valid) {
@@ -415,7 +421,7 @@ cbdataReferenceValid(const void *p)
 
     c->check(__LINE__);
 
-    assert(c->LockCount() > 0);
+    assert(c->locks > 0);
 
     return c->valid;
 }
@@ -456,8 +462,8 @@ cbdata::dump(StoreEntry *sentry) const
 #else
     void *p = (void *)&data;
 #endif
-    storeAppendPrintf(sentry, "%c%p\t%d\t%u\t%20s:%-5d\n", valid ? ' ' :
-                      '!', p, type, LockCount(), file, line);
+    storeAppendPrintf(sentry, "%c%p\t%d\t%d\t%20s:%-5d\n", valid ? ' ' :
+                      '!', p, type, locks, file, line);
 }
 
 struct CBDataDumper : public unary_function<cbdata, void> {
@@ -475,7 +481,7 @@ struct CBDataDumper : public unary_function<cbdata, void> {
 static void
 cbdataDump(StoreEntry * sentry)
 {
-    storeAppendPrintf(sentry, "%" PRIu64 " cbdata entries\n", cbdataCount);
+    storeAppendPrintf(sentry, "%d cbdata entries\n", cbdataCount);
 #if USE_CBDATA_DEBUG
 
     storeAppendPrintf(sentry, "Pointer\tType\tLocks\tAllocated by\n");
@@ -537,7 +543,7 @@ struct CBDataHistoryDumper : public CBDataDumper {
 void
 cbdataDumpHistory(StoreEntry *sentry)
 {
-    storeAppendPrintf(sentry, "%" PRIu64 " cbdata entries\n", cbdataCount);
+    storeAppendPrintf(sentry, "%d cbdata entries\n", cbdataCount);
     storeAppendPrintf(sentry, "Pointer\tType\tLocks\tAllocated by\n");
     CBDataHistoryDumper dumper(sentry);
     for_each (cbdataEntries, dumper);