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

Unified Diff: mojo/system/message_pipe_dispatcher.cc

Issue 240133005: Mojo: Make some attempts towards fixing remote message pipe closure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix some locking issues Created 6 years, 8 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 | « mojo/system/message_pipe.cc ('k') | mojo/system/message_pipe_endpoint.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/message_pipe_dispatcher.cc
diff --git a/mojo/system/message_pipe_dispatcher.cc b/mojo/system/message_pipe_dispatcher.cc
index 364259bd72a9223470bf8bd56c6b32b0af73788c..fc626efb714a531ee27b744cdc25a6e355e93f75 100644
--- a/mojo/system/message_pipe_dispatcher.cc
+++ b/mojo/system/message_pipe_dispatcher.cc
@@ -73,8 +73,21 @@ scoped_refptr<MessagePipeDispatcher> MessagePipeDispatcher::Deserialize(
MessageInTransit::EndpointId remote_id =
static_cast<const SerializedMessagePipeDispatcher*>(source)->endpoint_id;
+ if (remote_id == MessageInTransit::kInvalidEndpointId) {
+ // This means that the other end was closed, and there were no messages
+ // enqueued for us.
+ // TODO(vtl): This is wrong. We should produce a "dead" message pipe
+ // dispatcher.
+ NOTIMPLEMENTED();
+ return scoped_refptr<MessagePipeDispatcher>();
+ }
MessageInTransit::EndpointId local_id =
channel->AttachMessagePipeEndpoint(remote_message_pipe.second, 1);
+ if (local_id == MessageInTransit::kInvalidEndpointId) {
+ LOG(ERROR) << "Failed to deserialize message pipe dispatcher (failed to "
+ "attach; remote ID = " << remote_id << ")";
+ return scoped_refptr<MessagePipeDispatcher>();
+ }
DVLOG(2) << "Deserializing message pipe dispatcher (remote ID = "
<< remote_id << ", new local ID = " << local_id << ")";
@@ -199,8 +212,11 @@ bool MessagePipeDispatcher::EndSerializeAndCloseImplNoLock(
// Attach the new proxy endpoint to the channel.
MessageInTransit::EndpointId endpoint_id =
channel->AttachMessagePipeEndpoint(message_pipe_, port_);
- DCHECK_NE(endpoint_id, MessageInTransit::kInvalidEndpointId);
-
+ // Note: It's okay to get an endpoint ID of |kInvalidEndpointId|. (It's
+ // possible that the other endpoint -- the one that we're not sending -- was
+ // closed in the intervening time.) In that case, we need to deserialize a
+ // "dead" message pipe dispatcher on the other end. (Note that this is
+ // different from just producing |MOJO_HANDLE_INVALID|.)
DVLOG(2) << "Serializing message pipe dispatcher (local ID = " << endpoint_id
<< ")";
« no previous file with comments | « mojo/system/message_pipe.cc ('k') | mojo/system/message_pipe_endpoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698