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

Unified Diff: base/synchronization/waitable_event_posix.cc

Issue 419773002: Take extra lock in base::WaitableEvent::WaitMany. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/synchronization/waitable_event_posix.cc
diff --git a/base/synchronization/waitable_event_posix.cc b/base/synchronization/waitable_event_posix.cc
index fccba9d31c67c767b0b8172e10ad127ab2a5cb24..9eaf6b9c6c2d5d10343f17d8bcef32485aab5979 100644
--- a/base/synchronization/waitable_event_posix.cc
+++ b/base/synchronization/waitable_event_posix.cc
@@ -279,7 +279,7 @@ size_t WaitableEvent::WaitMany(WaitableEvent** raw_waitables,
// This will store the index of the raw_waitables which fired.
size_t signaled_index = 0;
- // Take the locks of each WaitableEvent in turn (except the signaled one) and
+ // Take the locks of each WaitableEvent in turn and
// remove our SyncWaiter from the wait-list
for (size_t i = 0; i < count; ++i) {
if (raw_waitables[i] != signaled_event) {
@@ -290,6 +290,11 @@ size_t WaitableEvent::WaitMany(WaitableEvent** raw_waitables,
raw_waitables[i]->kernel_->Dequeue(&sw, &sw);
raw_waitables[i]->kernel_->lock_.Release();
} else {
+ // We acquire and release the lock in order to ensure that the
agl 2014/07/25 17:32:46 It doesn't seem reasonable that WaitMany has this
yhirano 2014/07/29 06:48:11 TimedWait has the property because it acquires the
agl 2014/07/29 21:39:49 Ah, you have found a bug in the code! TimedWait ca
yhirano 2014/07/30 11:43:45 Hmm... I can easily find multiple code relying on
+ // corresponding |Signal| is done at this point.
+ raw_waitables[i]->kernel_->lock_.Acquire();
+ raw_waitables[i]->kernel_->lock_.Release();
+
signaled_index = i;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698