]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: pthread_cond_signal: don't need lock
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 20 Jan 2011 13:43:22 +0000 (05:43 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 20 Jan 2011 13:53:05 +0000 (05:53 -0800)
from the man page:

The pthread_cond_broadcast() or pthread_cond_signal() functions may be
called by a thread whether or not it currently owns the mutex that
threads calling pthread_cond_wait() or pthread_cond_timedwait() have
associated with the condition variable during their waits.

The man page goes on to suggest that sometimes you might want to hold
the lock when signalling. This would be the case if you had some
other variable that could only change when the lock was held, and you
wanted to ensure that that variable did not change prior to the waiter
being woken. That is not the case here, so it's irrelevant.

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/common/WorkQueue.h
src/osd/OSD.cc

index 1e0aaaf82655bb0653ee6a152680690114a71883..030d13a0c9238046ffdcee5fde8a81f540c73300 100644 (file)
@@ -91,8 +91,8 @@ public:
     void unlock() {
       pool->unlock();
     }
-    void _kick() {
-      pool->_kick();
+    void kick() {
+      pool->kick();
     }
     void drain() {
       pool->drain(this);
@@ -159,12 +159,6 @@ public:
   }
 
   void kick() {
-    _lock.Lock();
-    _cond.Signal();
-    _lock.Unlock();
-  }
-  void _kick() {
-    assert(_lock.is_locked());
     _cond.Signal();
   }
   void lock() {
index 567e11c1c1863cddd4b83eb6e81c1fe30e14ae21..cfc7793961a8ea75d472300cf4576d8097cb1535 100644 (file)
@@ -2094,7 +2094,7 @@ void OSD::handle_command(MMonCommand *m)
 
       defer_recovery_until = g_clock.now();
       defer_recovery_until += g_conf.osd_recovery_delay_start;
-      recovery_wq._kick();
+      recovery_wq.kick();
     }
   }
   else dout(0) << "unrecognized command! " << m->cmd << dendl;
@@ -4885,7 +4885,7 @@ void OSD::finish_recovery_op(PG *pg, const sobject_t& soid, bool dequeue)
     recovery_queue.push_front(&pg->recovery_item);  // requeue
   }
 
-  recovery_wq._kick();
+  recovery_wq.kick();
   recovery_wq.unlock();
 }
 
@@ -4897,7 +4897,7 @@ void OSD::defer_recovery(PG *pg)
   recovery_wq.lock();
   pg->get();
   recovery_queue.push_back(&pg->recovery_item);
-  recovery_wq._kick();
+  recovery_wq.kick();
   recovery_wq.unlock();
 }