Commit e69d711f authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

[mojo] Fix SequenceLocalSyncEventWatcher reset

There are (effectively rare) edge cases where
SequenceLocalSyncEventWatcher usage results in sequence's event staying
signaled despite having no more registered clients to notify.

This leaves the thread stuck in a state where any pending sync wait will
effectively busy-loop until it gets a reply rather than blocking as
intended.

This CL fixes the edge cases to ensure that the event in question is
always properly reset when appropriate.

Fixed: 11202650
Change-Id: Ib8542f6945b92d0fbfcc232143aba8bcf48f23a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2369676Reviewed-by: default avatarFabrice de Gans-Riberi <fdegans@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#801107}
parent 924421ae
......@@ -99,6 +99,8 @@ class SequenceLocalSyncEventWatcher::SequenceLocalState {
{
base::AutoLock lock(ready_watchers_lock_);
ready_watchers_.erase(iter->first);
if (ready_watchers_.empty())
event_.Reset();
}
registered_watchers_.erase(iter);
......@@ -206,8 +208,10 @@ void SequenceLocalSyncEventWatcher::SequenceLocalState::OnEventSignaled() {
base::AutoLock lock(ready_watchers_lock_);
std::swap(ready_watchers_, ready_watchers);
}
if (ready_watchers.empty())
if (ready_watchers.empty()) {
event_.Reset();
return;
}
auto weak_self = weak_ptr_factory_.GetWeakPtr();
for (auto* watcher : ready_watchers) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment