summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_channel_nacl.cc
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 00:49:17 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 00:49:17 +0000
commitcf0e7eea9e1a95206303c0c0ba8d90fa01d3e0f3 (patch)
tree3c528cf0a645af08851d5c67550c2e433d25cf4e /ipc/ipc_channel_nacl.cc
parent331b803f65e8f994f9148024e8c2be6b465c6a6e (diff)
downloadchromium_src-cf0e7eea9e1a95206303c0c0ba8d90fa01d3e0f3.zip
chromium_src-cf0e7eea9e1a95206303c0c0ba8d90fa01d3e0f3.tar.gz
chromium_src-cf0e7eea9e1a95206303c0c0ba8d90fa01d3e0f3.tar.bz2
PPAPI/NaCl: Make ipc_channel_nacl post to the correct thread.
Connect is called on the thread where Channel::Send will be invoked (and where messages should be dispatched). But Channel might be _created_ on some other thread. Therefore, we need to post data that we read to the thread on which Connect is called. NOT the thread where the Channel was created. This fixes an issue where sync messages were never getting their replies, because the DidRecvMsg task was being run on the thread where ChannelProxy::Send was called, not the Channel thread (which is the IO thread in this case). BUG=116317 TEST= Review URL: https://chromiumcodereview.appspot.com/10698138 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146006 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_channel_nacl.cc')
-rw-r--r--ipc/ipc_channel_nacl.cc27
1 files changed, 16 insertions, 11 deletions
diff --git a/ipc/ipc_channel_nacl.cc b/ipc/ipc_channel_nacl.cc
index 4dec85b..628b8a1 100644
--- a/ipc/ipc_channel_nacl.cc
+++ b/ipc/ipc_channel_nacl.cc
@@ -132,17 +132,6 @@ Channel::ChannelImpl::ChannelImpl(const IPC::ChannelHandle& channel_handle,
LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name
<< "\" in " << modestr << " mode";
}
- reader_thread_runner_.reset(
- new ReaderThreadRunner(
- pipe_,
- base::Bind(&Channel::ChannelImpl::DidRecvMsg,
- weak_ptr_factory_.GetWeakPtr()),
- base::Bind(&Channel::ChannelImpl::ReadDidFail,
- weak_ptr_factory_.GetWeakPtr()),
- base::MessageLoopProxy::current()));
- reader_thread_.reset(
- new base::DelegateSimpleThread(reader_thread_runner_.get(),
- "ipc_channel_nacl reader thread"));
}
Channel::ChannelImpl::~ChannelImpl() {
@@ -155,6 +144,22 @@ bool Channel::ChannelImpl::Connect() {
return false;
}
+ // Note that Connect is called on the "Channel" thread (i.e., the same thread
+ // where Channel::Send will be called, and the same thread that should receive
+ // messages). The constructor might be invoked on another thread (see
+ // ChannelProxy for an example of that). Therefore, we must wait until Connect
+ // is called to decide which MessageLoopProxy to pass to ReaderThreadRunner.
+ reader_thread_runner_.reset(
+ new ReaderThreadRunner(
+ pipe_,
+ base::Bind(&Channel::ChannelImpl::DidRecvMsg,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&Channel::ChannelImpl::ReadDidFail,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::MessageLoopProxy::current()));
+ reader_thread_.reset(
+ new base::DelegateSimpleThread(reader_thread_runner_.get(),
+ "ipc_channel_nacl reader thread"));
reader_thread_->Start();
waiting_connect_ = false;
// If there were any messages queued before connection, send them.