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

Unified Diff: mojo/edk/system/message_pipe_dispatcher.cc

Issue 1943123002: Make it possible to write a message pipe endpoint's peer into it. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 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
Index: mojo/edk/system/message_pipe_dispatcher.cc
diff --git a/mojo/edk/system/message_pipe_dispatcher.cc b/mojo/edk/system/message_pipe_dispatcher.cc
index 005b0948e740a0dd356c34fcb2fe44e922e9d09a..a0d5d02b62dead1c22f9ad19f8ae2f4b4dcf6aeb 100644
--- a/mojo/edk/system/message_pipe_dispatcher.cc
+++ b/mojo/edk/system/message_pipe_dispatcher.cc
@@ -133,9 +133,22 @@ void MessagePipeDispatcher::CloseImplNoLock() {
}
RefPtr<Dispatcher>
-MessagePipeDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() {
+MessagePipeDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock(
+ MessagePipe* message_pipe,
+ unsigned port) {
mutex().AssertHeld();
+ // "We" are being sent over our peer.
+ if (message_pipe == message_pipe_.get()) {
+ // A message pipe dispatcher can't be sent over itself (this should be
+ // disallowed by |Core|). Note that |port| is the destination port.
+ DCHECK_EQ(port, port_);
+ // In this case, |message_pipe_|'s mutex should already be held!
+ message_pipe_->CancelAllAwakablesNoLock(port_);
+ } else {
+ CancelAllAwakablesNoLock();
+ }
+
// TODO(vtl): Currently, there are no options, so we just use
// |kDefaultCreateOptions|. Eventually, we'll have to duplicate the options
// too.
@@ -220,14 +233,5 @@ bool MessagePipeDispatcher::EndSerializeAndCloseImplNoLock(
return rv;
}
-// MessagePipeDispatcherTransport ----------------------------------------------
-
-MessagePipeDispatcherTransport::MessagePipeDispatcherTransport(
- DispatcherTransport transport)
- : DispatcherTransport(transport) {
- DCHECK_EQ(message_pipe_dispatcher()->GetType(),
- Dispatcher::Type::MESSAGE_PIPE);
-}
-
} // namespace system
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698