Skip to content

Commit

Permalink
IPC::ChannelMojo: Don't supress MOJO_RESULT_FAILED_PRECONDITION
Browse files Browse the repository at this point in the history
The error should be reported to IPC::Listener as it is a
signal of the dead peer. Without this, the browser cannot
detect renderer crashes.

TEST=browser_tests (with ChannelMojo enabled)
R=viettrungluu@chromium.org,darin@chromium.org
BUG=none

Review URL: https://codereview.chromium.org/453643003

Cr-Commit-Position: refs/heads/master@{#288442}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288442 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
morrita@chromium.org committed Aug 8, 2014
1 parent fa5f474 commit e5c2775
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 10 additions & 2 deletions ipc/mojo/ipc_channel_mojo_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ namespace {

class ListenerThatExpectsOK : public IPC::Listener {
public:
ListenerThatExpectsOK() {}
ListenerThatExpectsOK()
: received_ok_(false) {}

virtual ~ListenerThatExpectsOK() {}

Expand All @@ -31,12 +32,16 @@ class ListenerThatExpectsOK : public IPC::Listener {
std::string should_be_ok;
EXPECT_TRUE(iter.ReadString(&should_be_ok));
EXPECT_EQ(should_be_ok, "OK");
received_ok_ = true;
base::MessageLoop::current()->Quit();
return true;
}

virtual void OnChannelError() OVERRIDE {
NOTREACHED();
// The connection should be healthy while the listener is waiting
// message. An error can occur after that because the peer
// process dies.
DCHECK(received_ok_);
}

static void SendOK(IPC::Sender* sender) {
Expand All @@ -45,6 +50,9 @@ class ListenerThatExpectsOK : public IPC::Listener {
message->WriteString(std::string("OK"));
ASSERT_TRUE(sender->Send(message));
}

private:
bool received_ok_;
};

class ListenerThatShouldBeNeverCalled : public IPC::Listener {
Expand Down
12 changes: 6 additions & 6 deletions ipc/mojo/ipc_message_pipe_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ void MessagePipeReader::PipeIsReady(MojoResult wait_result) {
pipe_wait_id_ = 0;

if (wait_result != MOJO_RESULT_OK) {
// FAILED_PRECONDITION happens when the pipe is
// closed before the waiter is scheduled in a backend thread.
if (wait_result != MOJO_RESULT_ABORTED &&
wait_result != MOJO_RESULT_FAILED_PRECONDITION) {
DLOG(WARNING) << "Pipe got error from the waiter. Closing: "
<< wait_result;
if (wait_result != MOJO_RESULT_ABORTED) {
// FAILED_PRECONDITION happens every time the peer is dead so
// it isn't worth polluting the log message.
DLOG_IF(WARNING, wait_result != MOJO_RESULT_FAILED_PRECONDITION)
<< "Pipe got error from the waiter. Closing: "
<< wait_result;
OnPipeError(wait_result);
}

Expand Down

0 comments on commit e5c2775

Please sign in to comment.