Skip to content

Commit

Permalink
ChannelMojo: Don't signal Channel errors with lock held
Browse files Browse the repository at this point in the history
This eliminates a lock-order inversion between ChannelMojo
and SyncMessageFilter.

BUG=611338
[email protected]

Review-Url: https://codereview.chromium.org/2000213002
Cr-Commit-Position: refs/heads/master@{#395483}
(cherry picked from commit 06325bc)

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

Cr-Commit-Position: refs/branch-heads/2743@{crosswalk-project#43}
Cr-Branched-From: 2b3ae3b-refs/heads/master@{#394939}
  • Loading branch information
krockot committed May 24, 2016
1 parent 0901e14 commit 9aae238
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions ipc/mojo/ipc_channel_mojo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,20 @@ void ChannelMojo::OnPipeError() {
}

bool ChannelMojo::Send(Message* message) {
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_;
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 (!message_reader_->Send(base::WrapUnique(message))) {
if (!sent) {
OnPipeError();
return false;
}
Expand Down

0 comments on commit 9aae238

Please sign in to comment.