mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 13:25:37 +00:00
Bug 1052740 - Cancel LazyIdleThread timer before shutting down its thread, r=bsmedberg.
This commit is contained in:
parent
552a1eafab
commit
bbf77ff477
@ -229,14 +229,16 @@ LazyIdleThread::ScheduleTimer()
|
||||
shouldSchedule = !mIdleNotificationCount && !mPendingEventCount;
|
||||
}
|
||||
|
||||
if (NS_FAILED(mIdleTimer->Cancel())) {
|
||||
NS_WARNING("Failed to cancel timer!");
|
||||
}
|
||||
if (mIdleTimer) {
|
||||
if (NS_FAILED(mIdleTimer->Cancel())) {
|
||||
NS_WARNING("Failed to cancel timer!");
|
||||
}
|
||||
|
||||
if (shouldSchedule &&
|
||||
NS_FAILED(mIdleTimer->InitWithCallback(this, mIdleTimeoutMS,
|
||||
nsITimer::TYPE_ONE_SHOT))) {
|
||||
NS_WARNING("Failed to schedule timer!");
|
||||
if (shouldSchedule &&
|
||||
NS_FAILED(mIdleTimer->InitWithCallback(this, mIdleTimeoutMS,
|
||||
nsITimer::TYPE_ONE_SHOT))) {
|
||||
NS_WARNING("Failed to schedule timer!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,6 +254,18 @@ LazyIdleThread::ShutdownThread()
|
||||
|
||||
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 =
|
||||
@ -311,15 +325,6 @@ LazyIdleThread::ShutdownThread()
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user