mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 840673: Shut down the timer before shutting down the thread, so that spinning the event loop while shutting down the thread does not cause us to see the timer firing and reenter. r=bent
This commit is contained in:
parent
4a04f7ad3a
commit
6c64536e24
@ -11,6 +11,7 @@
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -234,6 +235,17 @@ 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<nsresult> rv =
|
||||
mIdleTimer->Cancel();
|
||||
// nsTimerImpl::Cancel is infallible.
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
mIdleTimer = nullptr;
|
||||
}
|
||||
|
||||
if (mThread) {
|
||||
if (mShutdownMethod == AutomaticShutdown && NS_IsMainThread()) {
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
@ -260,7 +272,7 @@ LazyIdleThread::ShutdownThread()
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
NS_NewRunnableMethod(this, &LazyIdleThread::CleanupThread);
|
||||
NS_ENSURE_TRUE(runnable, NS_ERROR_FAILURE);
|
||||
MOZ_ASSERT(runnable);
|
||||
|
||||
PreDispatch();
|
||||
|
||||
@ -289,13 +301,6 @@ 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.
|
||||
|
Loading…
Reference in New Issue
Block a user