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

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

Issue 2037793003: Mojo C++ bindings: handle double peer endpoint closed event for the same endpoint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2f547bc2e52cf81ae0b7b6315b17e52278bdcab2..f05461840b271783a323e6d90dfd953fe75fcecf 100644
--- a/mojo/public/cpp/bindings/lib/multiplex_router.cc
+++ b/mojo/public/cpp/bindings/lib/multiplex_router.cc
@@ -526,11 +526,18 @@ bool MultiplexRouter::OnPeerAssociatedEndpointClosed(InterfaceId id) {
return false;
InterfaceEndpoint* endpoint = FindOrInsertEndpoint(id, nullptr);
- DCHECK(!endpoint->peer_closed());
- if (endpoint->client())
- tasks_.push_back(Task::CreateNotifyErrorTask(endpoint));
- UpdateEndpointStateMayRemove(endpoint, PEER_ENDPOINT_CLOSED);
+ // It is possible that this endpoint has been set as peer closed. That is
+ // because when the message pipe is closed, all the endpoints are updated with
+ // PEER_ENDPOINT_CLOSED. We continue to process remaining tasks in the queue,
+ // as long as there are refs keeping the router alive. If there is a
+ // PeerAssociatedEndpointClosedEvent control message in the queue, we will get
+ // here and see that the endpoint has been marked as peer closed.
+ if (!endpoint->peer_closed()) {
+ if (endpoint->client())
+ tasks_.push_back(Task::CreateNotifyErrorTask(endpoint));
+ UpdateEndpointStateMayRemove(endpoint, PEER_ENDPOINT_CLOSED);
+ }
// No need to trigger a ProcessTasks() because it is already on the stack.
« 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