Index: mojo/system/message_pipe.cc |
diff --git a/mojo/system/message_pipe.cc b/mojo/system/message_pipe.cc |
index b9643524f77f49bf3f8a36d7561ec54fcac7f3b0..01b05eedd12715d25dc87dc6225fe4caab3dde0a 100644 |
--- a/mojo/system/message_pipe.cc |
+++ b/mojo/system/message_pipe.cc |
@@ -136,7 +136,19 @@ MojoResult MessagePipe::EnqueueMessage( |
return MOJO_RESULT_FAILED_PRECONDITION; |
} |
- return endpoints_[port]->EnqueueMessage(message, dispatchers); |
+ MojoResult result = endpoints_[port]->CanEnqueueMessage(message, dispatchers); |
+ if (result != MOJO_RESULT_OK) { |
+ message->Destroy(); |
+ return result; |
+ } |
+ |
+ // TODO(vtl): No endpoints currently support transferring dispatchers, so we |
+ // can get away with this. What we really need to do is create equivalent |
+ // dispatchers here (and close the original dispatchers). |
+ DCHECK(!dispatchers); |
+ |
+ endpoints_[port]->EnqueueMessage(message, NULL); |
+ return MOJO_RESULT_OK; |
} |
void MessagePipe::Attach(unsigned port, |