Bug 545757: Don't post replies to the IO thread after a connection error. r=bent
authorChris Jones <jones.chris.g@gmail.com>
Thu, 11 Feb 2010 17:33:53 -0600
changeset 46671 ab07afb8c04ccc8216cd483f6787724860656b72
parent 46670 2efb17a8af6599ecd11cd8e96f1c7eeeeb87edc0
child 46672 959add9a851a4ea8787f5d4fb7fb9e0cb1a1d870
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbent
bugs545757
milestone1.9.3a2pre
Bug 545757: Don't post replies to the IO thread after a connection error. r=bent
ipc/glue/RPCChannel.cpp
ipc/glue/SyncChannel.cpp
--- a/ipc/glue/RPCChannel.cpp
+++ b/ipc/glue/RPCChannel.cpp
@@ -434,19 +434,23 @@ RPCChannel::DispatchIncall(const Message
         reply = new Message();
         reply->set_rpc();
         reply->set_reply();
         reply->set_reply_error();
     }
 
     reply->set_seqno(call.seqno());
 
-    mIOLoop->PostTask(
-        FROM_HERE,
-        NewRunnableMethod(this, &RPCChannel::OnSend, reply));
+    {
+        MutexAutoLock lock(mMutex);
+        if (ChannelConnected == mChannelState)
+            mIOLoop->PostTask(
+                FROM_HERE,
+                NewRunnableMethod(this, &RPCChannel::OnSend, reply));
+    }
 }
 
 bool
 RPCChannel::BlockChild()
 {
     AssertWorkerThread();
 
     if (mChild)
--- a/ipc/glue/SyncChannel.cpp
+++ b/ipc/glue/SyncChannel.cpp
@@ -163,19 +163,23 @@ SyncChannel::OnDispatchMessage(const Mes
         reply = new Message();
         reply->set_sync();
         reply->set_reply();
         reply->set_reply_error();
     }
 
     reply->set_seqno(msg.seqno());
 
-    mIOLoop->PostTask(
-        FROM_HERE,
-        NewRunnableMethod(this, &SyncChannel::OnSend, reply));
+    {
+        MutexAutoLock lock(mMutex);
+        if (ChannelConnected == mChannelState)
+            mIOLoop->PostTask(
+                FROM_HERE,
+                NewRunnableMethod(this, &SyncChannel::OnSend, reply));
+    }
 }
 
 //
 // The methods below run in the context of the IO thread, and can proxy
 // back to the methods above
 //
 
 void