]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
WorkQueue: add/remove_work_queue methods now thread safe 5991/head
authorJason Dillaman <dillaman@redhat.com>
Mon, 10 Aug 2015 23:10:19 +0000 (19:10 -0400)
committerNathan Cutler <ncutler@suse.cz>
Sat, 19 Sep 2015 18:56:26 +0000 (20:56 +0200)
These methods were not acquiring the ThreadPool lock when
manipulating the work_queue collection.  This was causing
occasional crashes within librbd when opening and closing
images.

Fixes: #12662
Backport: hammer, firefly
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 3e18449b01c1ab78d1bbfc1cf111aa9bdbef7b1f)

src/common/WorkQueue.h

index 53bed77a50ff98798c612d6c08e9ea32504a6358..a9eaffb7fbbe0c8e5c9beb86cc480aa49d31a0bd 100644 (file)
@@ -340,10 +340,12 @@ public:
   
   /// assign a work queue to this thread pool
   void add_work_queue(WorkQueue_* wq) {
+    Mutex::Locker l(_lock);
     work_queues.push_back(wq);
   }
   /// remove a work queue from this thread pool
   void remove_work_queue(WorkQueue_* wq) {
+    Mutex::Locker l(_lock);
     unsigned i = 0;
     while (work_queues[i] != wq)
       i++;