From: Jason Dillaman Date: Mon, 10 Aug 2015 23:10:19 +0000 (-0400) Subject: WorkQueue: add/remove_work_queue methods now thread safe X-Git-Tag: v0.80.11~15^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8c14cad0895590f19a6640c945b52213f30a9671;p=ceph.git WorkQueue: add/remove_work_queue methods now thread safe 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 (cherry picked from commit 3e18449b01c1ab78d1bbfc1cf111aa9bdbef7b1f) --- diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index 53bed77a50ff9..a9eaffb7fbbe0 100644 --- a/src/common/WorkQueue.h +++ b/src/common/WorkQueue.h @@ -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++;