common/shared_cache: dump weak refs on shutdown

Before asserting, dump what the refs are along with the counts.

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2014-08-22 09:17:06 -07:00
parent 6cf583c4b7
commit f246b56926

View File

@ -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<K, WeakVPtr>::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
{