Backed out changeset 3d4a094ac17e (bug 976790) for bustage on a CLOSED TREE.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 26 Feb 2014 16:52:29 -0500
changeset 171163 0a61ab3b106c04d0e2062cf852f76deb05ff139f
parent 171162 6b08917b4d2fef32a7de9b4110ed348375cc0a82
child 171164 75b8e45e9beb630512d705cebb306c04896d631a
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
bugs976790
milestone30.0a1
backs out3d4a094ac17e373b5b242a636d0bb7d0686519ee
Backed out changeset 3d4a094ac17e (bug 976790) for bustage on a CLOSED TREE.
ipc/glue/BackgroundImpl.cpp
--- a/ipc/glue/BackgroundImpl.cpp
+++ b/ipc/glue/BackgroundImpl.cpp
@@ -1,15 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "base/process_util.h"
 #include "mozilla/Assertions.h"
-#include "mozilla/Atomics.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/ipc/ProtocolTypes.h"
 #include "BackgroundChild.h"
@@ -137,17 +136,17 @@ private:
   // background thread. It is specific to each instance of sBackgroundThread.
   static nsTArray<ParentImpl*>* sLiveActorsForBackgroundThread;
 
   // This is only modified on the main thread.
   static StaticRefPtr<nsITimer> sShutdownTimer;
 
   // This exists so that that [Assert]IsOnBackgroundThread() can continue to
   // work during shutdown.
-  static Atomic<PRThread*> sBackgroundPRThread;
+  static PRThread* sBackgroundPRThread;
 
   // This is only modified on the main thread. It is null if the thread does not
   // exist or is shutting down.
   static MessageLoop* sBackgroundThreadMessageLoop;
 
   // This is only modified on the main thread. It maintains a count of live
   // actors so that the background thread can be shut down when it is no longer
   // needed.
@@ -793,17 +792,17 @@ const ParentImpl::ProcessHandle ParentIm
 #endif
 
 StaticRefPtr<nsIThread> ParentImpl::sBackgroundThread;
 
 nsTArray<ParentImpl*>* ParentImpl::sLiveActorsForBackgroundThread;
 
 StaticRefPtr<nsITimer> ParentImpl::sShutdownTimer;
 
-Atomic<PRThread*> ParentImpl::sBackgroundPRThread = nullptr;
+PRThread* ParentImpl::sBackgroundPRThread = nullptr;
 
 MessageLoop* ParentImpl::sBackgroundThreadMessageLoop = nullptr;
 
 uint64_t ParentImpl::sLiveActorCount = 0;
 
 bool ParentImpl::sShutdownObserverRegistered = false;
 
 bool ParentImpl::sShutdownHasStarted = false;
@@ -1245,27 +1244,27 @@ ParentImpl::RequestMessageLoopRunnable::
     return NS_OK;
   }
 
   char stackBaseGuess;
   profiler_register_thread("IPDL Background", &stackBaseGuess);
 
 #ifdef DEBUG
   {
+    PRThread* currentPRThread = PR_GetCurrentThread();
+    MOZ_ASSERT(currentPRThread);
+    MOZ_ASSERT_IF(sBackgroundPRThread, currentPRThread != sBackgroundPRThread);
+
     bool correctThread;
     MOZ_ASSERT(NS_SUCCEEDED(mTargetThread->IsOnCurrentThread(&correctThread)));
     MOZ_ASSERT(correctThread);
   }
 #endif
 
-  DebugOnly<PRThread*> oldBackgroundThread =
-    sBackgroundPRThread.exchange(PR_GetCurrentThread());
-
-  MOZ_ASSERT_IF(oldBackgroundThread,
-                PR_GetCurrentThread() != oldBackgroundThread);
+  sBackgroundPRThread = PR_GetCurrentThread();
 
   MOZ_ASSERT(!mMessageLoop);
 
   mMessageLoop = MessageLoop::current();
   MOZ_ASSERT(mMessageLoop);
 
   if (NS_FAILED(NS_DispatchToMainThread(this, NS_DISPATCH_NORMAL))) {
     NS_WARNING("Failed to dispatch RequestMessageLoopRunnable to main thread!");
@@ -1277,21 +1276,17 @@ ParentImpl::RequestMessageLoopRunnable::
 
 NS_IMPL_ISUPPORTS_INHERITED0(ParentImpl::ShutdownBackgroundThreadRunnable,
                              nsRunnable)
 
 NS_IMETHODIMP
 ParentImpl::ShutdownBackgroundThreadRunnable::Run()
 {
   AssertIsInMainProcess();
-
-  // It is possible that another background thread was created while this thread
-  // was shutting down. In that case we can't assert anything about
-  // sBackgroundPRThread and we should not modify it here.
-  sBackgroundPRThread.compareExchange(PR_GetCurrentThread(), nullptr);
+  AssertIsOnBackgroundThread();
 
   profiler_unregister_thread();
 
   return NS_OK;
 }
 
 NS_IMPL_ISUPPORTS_INHERITED0(ParentImpl::ForceCloseBackgroundActorsRunnable,
                              nsRunnable)