Bug 1051521 - Fix assertion when OnCloseChannel loses the race with OnChannelError. r=bsmedberg, a=bajaj B2G_2_0_20140902_MERGEDAY
authorBen Turner <bent.mozilla@gmail.com>
Mon, 11 Aug 2014 10:09:30 -0700
changeset 203821 1b4ac517798dc4f3d2e953f7df1c6833609cef69
parent 203820 b01206224fe850b07d1622c974d21540301896b1
child 203822 8ce3a902ceff0f3d512311090565f0bf967e9eb2
push id256
push userryanvm@gmail.com
push dateTue, 02 Sep 2014 13:36:16 +0000
treeherdermozilla-b2g32_v2_0@1b4ac517798d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, bajaj
bugs1051521
milestone32.0
Bug 1051521 - Fix assertion when OnCloseChannel loses the race with OnChannelError. r=bsmedberg, a=bajaj
ipc/glue/MessageLink.cpp
--- a/ipc/glue/MessageLink.cpp
+++ b/ipc/glue/MessageLink.cpp
@@ -11,16 +11,17 @@
 #include "mozilla/ipc/ProtocolUtils.h"
 
 #ifdef MOZ_NUWA_PROCESS
 #include "ipc/Nuwa.h"
 #include "mozilla/Preferences.h"
 #endif
 
 #include "mozilla/Assertions.h"
+#include "mozilla/DebugOnly.h"
 #include "nsDebug.h"
 #include "nsISupportsImpl.h"
 #include "nsXULAppAPI.h"
 
 using namespace mozilla;
 using namespace std;
 
 template<>
@@ -366,17 +367,22 @@ void
 ProcessLink::OnCloseChannel()
 {
     AssertIOThread();
 
     mTransport->Close();
 
     MonitorAutoLock lock(*mChan->mMonitor);
 
-    MOZ_ALWAYS_TRUE(this == mTransport->set_listener(mExistingListener));
+    DebugOnly<IPC::Channel::Listener*> previousListener =
+      mTransport->set_listener(mExistingListener);
+
+    // OnChannelError may have reset the listener already.
+    MOZ_ASSERT(previousListener == this ||
+               previousListener == mExistingListener);
 
     mChan->mChannelState = ChannelClosed;
     mChan->mMonitor->Notify();
 }
 
 bool
 ProcessLink::Unsound_IsClosed() const
 {