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

Unified Diff: mojo/public/cpp/bindings/lib/multiplex_router.cc

Issue 2684213002: Protect RefCount manipulation of InterfaceEndpoint with MultiplexRouter lock (Closed)
Patch Set: -MayAutoUnlock Created 3 years, 10 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: mojo/public/cpp/bindings/lib/multiplex_router.cc
diff --git a/mojo/public/cpp/bindings/lib/multiplex_router.cc b/mojo/public/cpp/bindings/lib/multiplex_router.cc
index 2d8c53e33994243be49eebb5b417f1b1764157ea..e188c4b4cddb6845b90d096dcc9746dcea3635e0 100644
--- a/mojo/public/cpp/bindings/lib/multiplex_router.cc
+++ b/mojo/public/cpp/bindings/lib/multiplex_router.cc
@@ -174,26 +174,23 @@ class MultiplexRouter::InterfaceEndpoint
void OnHandleReady(MojoResult result) {
DCHECK(task_runner_->BelongsToCurrentThread());
- scoped_refptr<InterfaceEndpoint> self_protector(this);
scoped_refptr<MultiplexRouter> router_protector(router_);
// Because we never close |sync_message_event_{sender,receiver}_| before
// destruction or set a deadline, |result| should always be MOJO_RESULT_OK.
DCHECK_EQ(MOJO_RESULT_OK, result);
- bool reset_sync_watcher = false;
- {
- MayAutoLock locker(router_->lock_.get());
- bool more_to_process = router_->ProcessFirstSyncMessageForEndpoint(id_);
+ MayAutoLock locker(router_->lock_.get());
+ scoped_refptr<InterfaceEndpoint> self_protector(this);
- if (!more_to_process)
- ResetSyncMessageSignal();
+ bool more_to_process = router_->ProcessFirstSyncMessageForEndpoint(id_);
- // Currently there are no queued sync messages and the peer has closed so
- // there won't be incoming sync messages in the future.
- reset_sync_watcher = !more_to_process && peer_closed_;
- }
- if (reset_sync_watcher) {
+ if (!more_to_process)
+ ResetSyncMessageSignal();
+
+ // Currently there are no queued sync messages and the peer has closed so
+ // there won't be incoming sync messages in the future.
+ if (!more_to_process && peer_closed_) {
// If a SyncWatch() call (or multiple ones) of this interface endpoint is
// on the call stack, resetting the sync watcher will allow it to exit
// when the call stack unwinds to that frame.
« 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