]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
atomic: assert valid ref counts
authorSage Weil <sage@newdream.net>
Thu, 19 Nov 2009 19:40:50 +0000 (11:40 -0800)
committerSage Weil <sage@newdream.net>
Thu, 19 Nov 2009 20:41:04 +0000 (12:41 -0800)
Make sure we catch ref counting errors!

src/include/atomic.h

index 9cd3f785dec0f6ab027b305aa0603c8285affafc..3a23170905baf1be967bc3c83182c5fd4a1de800 100644 (file)
@@ -56,6 +56,7 @@ public:
   }
   int dec() {
     lock.lock();
+    assert(nref > 0);
     int r = --nref; 
     lock.unlock();
     return r;
@@ -67,6 +68,7 @@ public:
   }
   void sub(int d) {
     lock.lock();
+    assert(nref >= d);
     nref -= d;
     lock.unlock();
   }