~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
{