]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cond: reorder asserts
authorSage Weil <sage@inktank.com>
Tue, 17 Jul 2012 20:52:00 +0000 (13:52 -0700)
committerSage Weil <sage@inktank.com>
Fri, 27 Jul 2012 17:43:25 +0000 (10:43 -0700)
Make the more specific checks assert before the less specific ones, so we
are more likely to crash with useful information.

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/Cond.h

index 902ce228e2736330c75d5afc326c73e23b58ebf7..da44aedc70d1609b81f041e6c9136cf59062e110 100644 (file)
@@ -45,12 +45,12 @@ class Cond {
   }
 
   int Wait(Mutex &mutex)  { 
-    assert(mutex.is_locked());
-
     // make sure this cond is used with one mutex only
     assert(waiter_mutex == NULL || waiter_mutex == &mutex);
     waiter_mutex = &mutex;
 
+    assert(mutex.is_locked());
+
     --mutex.nlock;
     int r = pthread_cond_wait(&_c, &mutex._m);
     ++mutex.nlock;
@@ -58,12 +58,12 @@ class Cond {
   }
 
   int WaitUntil(Mutex &mutex, utime_t when) {
-    assert(mutex.is_locked());
-
     // make sure this cond is used with one mutex only
     assert(waiter_mutex == NULL || waiter_mutex == &mutex);
     waiter_mutex = &mutex;
 
+    assert(mutex.is_locked());
+
     struct timespec ts;
     when.to_timespec(&ts);
     --mutex.nlock;