Backed out changeset 6e6bc1bcf229 (bug 1052740) for mochitest-bc crashes.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 20 Aug 2014 16:34:38 -0400
changeset 200702 dab4b1163d3d0dc22bb1e976c6fbaa1f987d065e
parent 200701 bf6096626941f8ca131c1aa9ef9edde83941708c
child 200703 15caaf563783b5523bb4000e9e4960d24c06e5b8
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs1052740
milestone34.0a1
backs out6e6bc1bcf229b950189f952b1f103eba2b51b4a3
Backed out changeset 6e6bc1bcf229 (bug 1052740) for mochitest-bc crashes. CLOSED TREE
xpcom/threads/LazyIdleThread.cpp
--- a/xpcom/threads/LazyIdleThread.cpp
+++ b/xpcom/threads/LazyIdleThread.cpp
@@ -247,28 +247,16 @@ LazyIdleThread::ShutdownThread()
 
   // Before calling Shutdown() on the real thread we need to put a queue in
   // place in case a runnable is posted to the thread while it's in the
   // process of shutting down. This will be our queue.
   nsAutoTArray<nsCOMPtr<nsIRunnable>, 10> queuedRunnables;
 
   nsresult rv;
 
-  // Make sure to cancel the shutdown timer before spinning the event loop
-  // during |mThread->Shutdown()| below. Otherwise the timer might fire and we
-  // could reenter here.
-  if (mIdleTimer) {
-    rv = mIdleTimer->Cancel();
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
-    }
-
-    mIdleTimer = nullptr;
-  }
-
   if (mThread) {
     if (mShutdownMethod == AutomaticShutdown && NS_IsMainThread()) {
       nsCOMPtr<nsIObserverService> obs =
         mozilla::services::GetObserverService();
       NS_WARN_IF_FALSE(obs, "Failed to get observer service!");
 
       if (obs &&
           NS_FAILED(obs->RemoveObserver(this, "xpcom-shutdown-threads"))) {
@@ -318,16 +306,25 @@ LazyIdleThread::ShutdownThread()
 
       MOZ_ASSERT(!mPendingEventCount, "Huh?!");
       MOZ_ASSERT(!mIdleNotificationCount, "Huh?!");
       MOZ_ASSERT(mThreadIsShuttingDown, "Huh?!");
       mThreadIsShuttingDown = false;
     }
   }
 
+  if (mIdleTimer) {
+    rv = mIdleTimer->Cancel();
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+
+    mIdleTimer = nullptr;
+  }
+
   // If our temporary queue has any runnables then we need to dispatch them.
   if (queuedRunnables.Length()) {
     // If the thread manager has gone away then these runnables will never run.
     if (mShutdown) {
       NS_ERROR("Runnables dispatched to LazyIdleThread will never run!");
       return NS_OK;
     }