Skip to content

Commit

Permalink
WorkQueue: add/remove_work_queue methods now thread safe
Browse files Browse the repository at this point in the history
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 3e18449)
  • Loading branch information
Jason Dillaman authored and Abhishek Varshney committed Sep 11, 2015
1 parent 6e22620 commit d8ac510
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/common/WorkQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,12 @@ class ThreadPool : public md_config_obs_t {

/// 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++;
Expand Down

0 comments on commit d8ac510

Please sign in to comment.