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

Unified Diff: ipc/ipc_channel_proxy.cc

Issue 183553004: Eliminate a potential race in IPC::ChannelProxy (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 10 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 | « ipc/ipc_channel_proxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_proxy.cc
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc
index 50431d575604c43045d174fa0800613bba17d463..de9f0230a03c875057e256a2f90098c45219629a 100644
--- a/ipc/ipc_channel_proxy.cc
+++ b/ipc/ipc_channel_proxy.cc
@@ -143,7 +143,8 @@ ChannelProxy::Context::Context(Listener* listener,
ipc_task_runner_(ipc_task_runner),
channel_connected_called_(false),
message_filter_router_(new MessageFilterRouter()),
- peer_pid_(base::kNullProcessId) {
+ peer_pid_(base::kNullProcessId),
+ channel_is_connected_(false) {
DCHECK(ipc_task_runner_.get());
}
@@ -200,6 +201,7 @@ void ChannelProxy::Context::OnChannelConnected(int32 peer_pid) {
// creates a ChannelProxy, calls AddFilter, and then right after starts the
// peer process. The IO thread could receive a message before the task to add
// the filter is run on the IO thread.
+ channel_is_connected_ = true;
OnAddFilter();
// We cache off the peer_pid so it can be safely accessed from both threads.
@@ -278,6 +280,9 @@ void ChannelProxy::Context::OnSendMessage(scoped_ptr<Message> message) {
// Called on the IPC::Channel thread
void ChannelProxy::Context::OnAddFilter() {
+ if (!channel_is_connected_)
+ return;
+
std::vector<scoped_refptr<MessageFilter> > new_filters;
{
base::AutoLock auto_lock(pending_filters_lock_);
« no previous file with comments | « ipc/ipc_channel_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698