diff --git a/xpcom/threads/LazyIdleThread.cpp b/xpcom/threads/LazyIdleThread.cpp index fb8d3451e40..9b40e27243e 100644 --- a/xpcom/threads/LazyIdleThread.cpp +++ b/xpcom/threads/LazyIdleThread.cpp @@ -11,7 +11,6 @@ #include "nsComponentManagerUtils.h" #include "nsServiceManagerUtils.h" #include "nsThreadUtils.h" -#include "mozilla/DebugOnly.h" #include "mozilla/Services.h" #ifdef DEBUG @@ -235,17 +234,6 @@ LazyIdleThread::ShutdownThread() nsresult rv; - // Do this up front so that when we spin the event loop to shutdown the - // thread the idle timer doesn't cause us to reenter. - if (mIdleTimer) { - DebugOnly rv = - mIdleTimer->Cancel(); - // nsTimerImpl::Cancel is infallible. - MOZ_ASSERT(NS_SUCCEEDED(rv)); - - mIdleTimer = nullptr; - } - if (mThread) { if (mShutdownMethod == AutomaticShutdown && NS_IsMainThread()) { nsCOMPtr obs = @@ -272,7 +260,7 @@ LazyIdleThread::ShutdownThread() nsCOMPtr runnable = NS_NewRunnableMethod(this, &LazyIdleThread::CleanupThread); - MOZ_ASSERT(runnable); + NS_ENSURE_TRUE(runnable, NS_ERROR_FAILURE); PreDispatch(); @@ -301,6 +289,13 @@ LazyIdleThread::ShutdownThread() } } + if (mIdleTimer) { + rv = mIdleTimer->Cancel(); + NS_ENSURE_SUCCESS(rv, 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.