Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2578)

Unified Diff: base/threading/sequenced_worker_pool.cc

Issue 994483005: Base: Fix another deadlock during shutdown of SequencedWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improve comments. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/threading/sequenced_worker_pool_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/sequenced_worker_pool.cc
diff --git a/base/threading/sequenced_worker_pool.cc b/base/threading/sequenced_worker_pool.cc
index f20d9972261c3b26269564ba3b198ce1aba1be49..52b178bcd5f42be4a71d45b692d5e879b033bf04 100644
--- a/base/threading/sequenced_worker_pool.cc
+++ b/base/threading/sequenced_worker_pool.cc
@@ -803,6 +803,20 @@ void SequencedWorkerPool::Inner::ThreadLoop(Worker* this_worker) {
delete_these_outside_lock.clear();
break;
}
+
+ // No work was found, but there are tasks that need deletion. The
+ // deletion must happen outside of the lock.
+ if (delete_these_outside_lock.size()) {
+ AutoUnlock unlock(lock_);
+ delete_these_outside_lock.clear();
+
+ // Since the lock has been released, |status| may no longer be
+ // accurate. It might read GET_WORK_WAIT even if there are tasks
+ // ready to perform work. Jump to the top of the loop to recalculate
+ // |status|.
+ continue;
+ }
+
waiting_thread_count_++;
switch (status) {
« no previous file with comments | « no previous file | base/threading/sequenced_worker_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698