Index: mojo/edk/system/remote_message_pipe_bootstrap.cc |
diff --git a/mojo/edk/system/remote_message_pipe_bootstrap.cc b/mojo/edk/system/remote_message_pipe_bootstrap.cc |
index 671542f3595c72615a74b18919d0bcd9dbd181bc..234216633f2fc074d39e29681fd4dec44f592cc1 100644 |
--- a/mojo/edk/system/remote_message_pipe_bootstrap.cc |
+++ b/mojo/edk/system/remote_message_pipe_bootstrap.cc |
@@ -31,18 +31,17 @@ struct BootstrapData { |
void RemoteMessagePipeBootstrap::Create( |
NodeController* node_controller, |
ScopedPlatformHandle platform_handle, |
- const ports::PortRef& port, |
- const base::Closure& callback) { |
+ const ports::PortRef& port) { |
if (node_controller->io_task_runner()->RunsTasksOnCurrentThread()) { |
// Owns itself. |
- new RemoteMessagePipeBootstrap(node_controller, std::move(platform_handle), |
- port, callback); |
+ new RemoteMessagePipeBootstrap( |
+ node_controller, std::move(platform_handle), port); |
} else { |
node_controller->io_task_runner()->PostTask( |
FROM_HERE, |
base::Bind(&RemoteMessagePipeBootstrap::Create, |
base::Unretained(node_controller), |
- base::Passed(&platform_handle), port, callback)); |
+ base::Passed(&platform_handle), port)); |
} |
} |
@@ -56,11 +55,9 @@ RemoteMessagePipeBootstrap::~RemoteMessagePipeBootstrap() { |
RemoteMessagePipeBootstrap::RemoteMessagePipeBootstrap( |
NodeController* node_controller, |
ScopedPlatformHandle platform_handle, |
- const ports::PortRef& port, |
- const base::Closure& callback) |
+ const ports::PortRef& port) |
: node_controller_(node_controller), |
local_port_(port), |
- callback_(callback), |
io_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
channel_(Channel::Create(this, std::move(platform_handle), |
io_task_runner_)) { |
@@ -119,8 +116,14 @@ void RemoteMessagePipeBootstrap::OnChannelMessage( |
} |
peer_info_received_ = true; |
- node_controller_->ConnectToRemotePort( |
- local_port_, data->node_name, data->port_name, callback_); |
+ |
+ // We need to choose one side to initiate the port merge. It doesn't matter |
+ // who does it as long as they don't both try. Simple solution: pick the one |
+ // with the "smaller" port name. |
+ if (local_port_.name() < data->port_name) { |
+ node_controller_->node()->MergePorts(local_port_, data->node_name, |
+ data->port_name); |
+ } |
// Send another ping to the other end to trigger shutdown. This may race with |
// the other end sending its own ping, but it doesn't matter. Whoever wins |