Bug 942118 - Ensure that we call MessageChannel::ReportConnectionError() with no lock. r=bent
authorAlexandre Lissy <lissyx@lissyx.dyndns.org>
Fri, 22 Nov 2013 17:29:25 +0100
changeset 162946 ee221e1e179f2e321eb715fbc8259a37841daaf7
parent 162945 6ccb56d8984e12d38c440f0398c8fa7952283427
child 162947 b18b224f2efb2215607654c210b1ee4766fe607b
push id25975
push userryanvm@gmail.com
push dateFri, 10 Jan 2014 19:46:47 +0000
treeherderautoland@e89afc241513 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs942118
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 942118 - Ensure that we call MessageChannel::ReportConnectionError() with no lock. r=bent Making a call to mListener with a mMonitor lock is bad. Most of the code path for ReportConnectionError() are doing this because they are just after the Connected() method which needs the lock. We ensure to unlock mMonitor in the scope of the ReportConnectionError() call.
ipc/glue/MessageChannel.cpp
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -1280,16 +1280,19 @@ MessageChannel::ReportMessageRouteError(
 {
     PrintErrorMessage(mSide, channelName, "Need a route");
     mListener->OnProcessingError(MsgRouteError);
 }
 
 void
 MessageChannel::ReportConnectionError(const char* aChannelName) const
 {
+    AssertWorkerThread();
+    mMonitor->AssertCurrentThreadOwns();
+
     const char* errorMsg = nullptr;
     switch (mChannelState) {
       case ChannelClosed:
         errorMsg = "Closed channel: cannot send/recv";
         break;
       case ChannelOpening:
         errorMsg = "Opening channel: not yet ready for send/recv";
         break;
@@ -1303,16 +1306,18 @@ MessageChannel::ReportConnectionError(co
         errorMsg = "Channel error: cannot send/recv";
         break;
 
       default:
         NS_RUNTIMEABORT("unreached");
     }
 
     PrintErrorMessage(mSide, aChannelName, errorMsg);
+
+    MonitorAutoUnlock unlock(*mMonitor);
     mListener->OnProcessingError(MsgDropped);
 }
 
 bool
 MessageChannel::MaybeHandleError(Result code, const char* channelName)
 {
     if (MsgProcessed == code)
         return true;