]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/common/RWLock.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / common / RWLock.h
index a1d8c88a30a4c8d4686ac90c82e0f2cc08b112b6..94ba7a00116401351e0b1e66010e974f3b07b4b6 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <pthread.h>
 #include <string>
-#include <include/assert.h>
+#include "include/ceph_assert.h"
 #include "acconfig.h"
 #include "lockdep.h"
 #include "common/valgrind.h"
@@ -53,6 +53,7 @@ public:
       pthread_rwlockattr_setkind_np(&attr,
           PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
       pthread_rwlock_init(&L, &attr);
+      pthread_rwlockattr_destroy(&attr);
     } else 
 #endif 
     // Next block is in {} to possibly connect to the above if when code is used.
@@ -66,19 +67,19 @@ public:
   }
 
   bool is_locked() const {
-    assert(track);
+    ceph_assert(track);
     return (nrlock > 0) || (nwlock > 0);
   }
 
   bool is_wlocked() const {
-    assert(track);
+    ceph_assert(track);
     return (nwlock > 0);
   }
   ~RWLock() {
     // The following check is racy but we are about to destroy
     // the object and we assume that there are no other users.
     if (track)
-      assert(!is_locked());
+      ceph_assert(!is_locked());
     pthread_rwlock_destroy(&L);
     if (lockdep && g_lockdep) {
       lockdep_unregister(id);
@@ -90,21 +91,21 @@ public:
       if (nwlock > 0) {
         nwlock--;
       } else {
-        assert(nrlock > 0);
+        ceph_assert(nrlock > 0);
         nrlock--;
       }
     }
     if (lockdep && this->lockdep && g_lockdep)
       id = lockdep_will_unlock(name.c_str(), id);
     int r = pthread_rwlock_unlock(&L);
-    assert(r == 0);
+    ceph_assert(r == 0);
   }
 
   // read
   void get_read() const {
     if (lockdep && g_lockdep) id = lockdep_will_lock(name.c_str(), id);
     int r = pthread_rwlock_rdlock(&L);
-    assert(r == 0);
+    ceph_assert(r == 0);
     if (lockdep && g_lockdep) id = lockdep_locked(name.c_str(), id);
     if (track)
       nrlock++;
@@ -127,7 +128,7 @@ public:
     if (lockdep && this->lockdep && g_lockdep)
       id = lockdep_will_lock(name.c_str(), id);
     int r = pthread_rwlock_wrlock(&L);
-    assert(r == 0);
+    ceph_assert(r == 0);
     if (lockdep && this->lockdep && g_lockdep)
       id = lockdep_locked(name.c_str(), id);
     if (track)
@@ -168,7 +169,7 @@ public:
       locked = true;
     }
     void unlock() {
-      assert(locked);
+      ceph_assert(locked);
       m_lock.unlock();
       locked = false;
     }
@@ -190,7 +191,7 @@ public:
       locked = true;
     }
     void unlock() {
-      assert(locked);
+      ceph_assert(locked);
       m_lock.unlock();
       locked = false;
     }
@@ -219,27 +220,27 @@ public:
     Context(RWLock& l, LockState s) : lock(l), state(s) {}
 
     void get_write() {
-      assert(state == Untaken);
+      ceph_assert(state == Untaken);
 
       lock.get_write();
       state = TakenForWrite;
     }
 
     void get_read() {
-      assert(state == Untaken);
+      ceph_assert(state == Untaken);
 
       lock.get_read();
       state = TakenForRead;
     }
 
     void unlock() {
-      assert(state != Untaken);
+      ceph_assert(state != Untaken);
       lock.unlock();
       state = Untaken;
     }
 
     void promote() {
-      assert(state == TakenForRead);
+      ceph_assert(state == TakenForRead);
       unlock();
       get_write();
     }