]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/shared_cache: dump weak refs on shutdown 2308/head
authorSage Weil <sage@redhat.com>
Fri, 22 Aug 2014 16:17:06 +0000 (09:17 -0700)
committerSage Weil <sage@redhat.com>
Fri, 22 Aug 2014 16:17:06 +0000 (09:17 -0700)
Before asserting, dump what the refs are along with the counts.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/shared_cache.hpp

index 8b48272ee411357c3148b317eadbc3c966d7ac42..f5f53f90aec621506fb49f7cf2789faedc7b3d3f 100644 (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
     {