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

Unified Diff: ipc/ipc_channel_mojo.cc

Issue 2136903002: With ChannelMojo, don't error the channel on Send failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simplify Created 4 years, 5 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: ipc/ipc_channel_mojo.cc
diff --git a/ipc/ipc_channel_mojo.cc b/ipc/ipc_channel_mojo.cc
index 66b0768ca1f62019363a4fd0e6bbeceb231f9ea7..22efa3a335f6a9594eda2dccad69497dc8579b80 100644
--- a/ipc/ipc_channel_mojo.cc
+++ b/ipc/ipc_channel_mojo.cc
@@ -356,25 +356,24 @@ void ChannelMojo::OnPipeError() {
}
bool ChannelMojo::Send(Message* message) {
- bool sent = false;
- {
- base::AutoLock lock(lock_);
- if (!message_reader_) {
- pending_messages_.push_back(base::WrapUnique(message));
- // Counts as OK before the connection is established, but it's an
- // error otherwise.
- return waiting_connect_;
- }
-
- sent = message_reader_->Send(base::WrapUnique(message));
- }
-
- if (!sent) {
- OnPipeError();
- return false;
+ base::AutoLock lock(lock_);
+ if (!message_reader_) {
+ pending_messages_.push_back(base::WrapUnique(message));
+ // Counts as OK before the connection is established, but it's an
+ // error otherwise.
+ return waiting_connect_;
}
- return true;
+ // Comment copied from ipc_channel_posix.cc:
+ // We can't close the pipe here, because calling OnChannelError may destroy
+ // this object, and that would be bad if we are called from Send(). Instead,
+ // we return false and hope the caller will close the pipe. If they do not,
+ // the pipe will still be closed next time OnFileCanReadWithoutBlocking is
+ // called.
+ //
+ // With Mojo, there's no OnFileCanReadWithoutBlocking, but we expect the
+ // pipe's connection error handler will be invoked in its place.
+ return message_reader_->Send(base::WrapUnique(message));
}
bool ChannelMojo::IsSendThreadSafe() const {
« 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