From bc40792d89178332d4f02d0ac680171c859ac0ba Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Fri, 10 Oct 2014 09:06:38 -0700 Subject: [PATCH] CBDATA: log memory leak situations when --enable-debug-cbdata CBDATA objects are supposed to be explicitly locked and unlocked by all users. The nominal 'owner' of the data is also supposed to mark it as invalid when unlocking its reference. If a CBDATA object reaches 0 locks and is still valid, it therefore follows that either the locking or invalidate has not been properly implemented. Now that we are migrating to CbcPointer usage instead of explicit lock/unlock macro calls we have started encountering these situations. Any object reporting a 'leak' must be investigated; a) perhapse RefCount is better? b) using CbcPointer consistently and invalidating correctly. --- src/cbdata.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cbdata.cc b/src/cbdata.cc index e8b1a4fee9..e7148d233a 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -434,9 +434,16 @@ cbdataInternalUnlock(const void *p) -- c->locks; - if (c->valid || c->locks) + if (c->locks) return; + if (c->valid) { +#if USE_CBDATA_DEBUG + debugs(45, DBG_IMPORTANT, "CBDATA memory leak. cbdata=" << p << " " << file << ":" << line); +#endif + return; + } + --cbdataCount; debugs(45, 9, "Freeing " << p); -- 2.47.3