Bug 1637890 - P4. Process events dispatched by destructors during shutdown. r=froydnj

We allow the last tasks dispatched during shutdown to be run rather than just leaking them.

Differential Revision: https://phabricator.services.mozilla.com/D75497
This commit is contained in:
Jean-Yves Avenard 2020-05-19 06:06:18 +00:00
Родитель 61fceb7c07
Коммит 38cfa9db61
1 изменённых файлов: 11 добавлений и 10 удалений

Просмотреть файл

@ -649,6 +649,17 @@ nsresult ShutdownXPCOM(nsIServiceManager* aServMgr) {
NS_ProcessPendingEvents(thread);
if (observerService) {
mozilla::KillClearOnShutdown(ShutdownPhase::ShutdownLoaders);
observerService->Shutdown();
}
// Free ClearOnShutdown()'ed smart pointers. This needs to happen *after*
// we've finished notifying observers of XPCOM shutdown, because shutdown
// observers themselves might call ClearOnShutdown().
// Some destructors may fire extra runnables that will be processed below.
mozilla::KillClearOnShutdown(ShutdownPhase::ShutdownFinal);
// Shutdown all remaining threads. This method does not return until
// all threads created using the thread manager (with the exception of
// the main thread) have exited.
@ -662,18 +673,8 @@ nsresult ShutdownXPCOM(nsIServiceManager* aServMgr) {
BackgroundHangMonitor().NotifyActivity();
mozilla::dom::JSExecutionManager::Shutdown();
if (observerService) {
mozilla::KillClearOnShutdown(ShutdownPhase::ShutdownLoaders);
observerService->Shutdown();
}
}
// Free ClearOnShutdown()'ed smart pointers. This needs to happen *after*
// we've finished notifying observers of XPCOM shutdown, because shutdown
// observers themselves might call ClearOnShutdown().
mozilla::KillClearOnShutdown(ShutdownPhase::ShutdownFinal);
AbstractThread::ShutdownMainThread();
mozilla::AppShutdown::MaybeFastShutdown(