From f246b56926f59420a2f2d022371e470c6cfa95fd Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 22 Aug 2014 09:17:06 -0700 Subject: [PATCH] common/shared_cache: dump weak refs on shutdown Before asserting, dump what the refs are along with the counts. Signed-off-by: Sage Weil --- src/common/shared_cache.hpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/common/shared_cache.hpp b/src/common/shared_cache.hpp index 8b48272ee41..f5f53f90aec 100644 --- a/src/common/shared_cache.hpp +++ b/src/common/shared_cache.hpp @@ -91,13 +91,29 @@ public: ~SharedLRU() { contents.clear(); lru.clear(); - assert(weak_refs.empty()); + if (!weak_refs.empty()) { + lderr(cct) << "leaked refs:\n"; + dump_weak_refs(*_dout); + *_dout << dendl; + assert(weak_refs.empty()); + } } void set_cct(CephContext *c) { cct = c; } + void dump_weak_refs(ostream& out) { + for (typename map::iterator p = weak_refs.begin(); + p != weak_refs.end(); + ++p) { + out << __func__ << " " << this << " weak_refs: " + << p->first << " = " << p->second.lock().get() + << " with " << p->second.use_count() << " refs" + << std::endl; + } + } + void clear(const K& key) { VPtr val; // release any ref we have after we drop the lock {