From: Amos Jeffries Date: Wed, 22 Apr 2015 11:06:20 +0000 (-0700) Subject: Revert rev.14029 X-Git-Tag: merge-candidate-3-v1~162 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20148bf2fb019708e44acd7f0670818eb6535ede;p=thirdparty%2Fsquid.git Revert rev.14029 --- diff --git a/src/cbdata.cc b/src/cbdata.cc index a92058085d..ad3c2e9aa1 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -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 + #if USE_CBDATA_DEBUG #include #include @@ -25,7 +26,7 @@ #include #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 { @@ -475,7 +481,7 @@ struct CBDataDumper : public unary_function { 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);