From a8cdc347529ba3839c8f13bd9133f05985faab5d Mon Sep 17 00:00:00 2001 From: "bsmedberg%covad.net" Date: Wed, 23 Nov 2005 20:21:46 +0000 Subject: [PATCH] Backing out even more of bug 316414 to try and fix orange. --- xpcom/build/nsXPComInit.cpp | 68 ++++++++++--------------------------- 1 file changed, 17 insertions(+), 51 deletions(-) diff --git a/xpcom/build/nsXPComInit.cpp b/xpcom/build/nsXPComInit.cpp index 3d31e7ae8001..76f48d6d31cb 100644 --- a/xpcom/build/nsXPComInit.cpp +++ b/xpcom/build/nsXPComInit.cpp @@ -72,7 +72,6 @@ #include "nsEventQueueService.h" #include "nsEventQueue.h" -#include "nsEventQueueUtils.h" #include "nsIProxyObjectManager.h" #include "nsProxyEventPrivate.h" // access to the impl of nsProxyObjectManager for the generic factory registration. @@ -143,6 +142,7 @@ extern void _FreeAutoLockStatics(); static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static NS_DEFINE_CID(kMemoryCID, NS_MEMORY_CID); +static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kINIParserFactoryCID, NS_INIPARSERFACTORY_CID); NS_GENERIC_FACTORY_CONSTRUCTOR(nsProcess) @@ -773,15 +773,11 @@ NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine) // // The shutdown sequence for xpcom would be // -// - Notify "xpcom-shutdown" for modules to release primary (root) references -// - Notify "xpcom-shutdown-threads" for thread joins -// - Shutdown the main event queue (TODO) // - Release the Global Service Manager // - Release all service instances held by the global service manager // - Release the Global Service Manager itself // - Release the Component Manager // - Release all factories cached by the Component Manager -// - Notify module loaders to shut down // - Unload Libraries // - Release Contractid Cache held by Component Manager // - Release dll abstraction held by Component Manager @@ -791,46 +787,37 @@ NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine) EXPORT_XPCOM_API(nsresult) NS_ShutdownXPCOM(nsIServiceManager* servMgr) { - nsresult rv; - - // grab the event queue so that we can process events before exiting. - nsCOMPtr currentQ; - NS_GetCurrentEventQ(getter_AddRefs(currentQ)); - - nsCOMPtr moduleLoaders; // Notify observers of xpcom shutting down + nsresult rv = NS_OK; { // Block it so that the COMPtr will get deleted before we hit // servicemanager shutdown nsCOMPtr observerService = - do_GetService("@mozilla.org/observer-service;1"); - - if (observerService) + do_GetService("@mozilla.org/observer-service;1", &rv); + if (NS_SUCCEEDED(rv)) { nsCOMPtr mgr; rv = NS_GetServiceManager(getter_AddRefs(mgr)); if (NS_SUCCEEDED(rv)) { - (void) observerService-> - NotifyObservers(mgr, NS_XPCOM_SHUTDOWN_OBSERVER_ID, - nsnull); + (void) observerService->NotifyObservers(mgr, + NS_XPCOM_SHUTDOWN_OBSERVER_ID, + nsnull); } } - - if (observerService) - (void) observerService-> - NotifyObservers(nsnull, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID, - nsnull); - - // We save the "xpcom-shutdown-loaders" observers to notify after - // the observerservice is gone. - if (observerService) - observerService-> - EnumerateObservers(NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID, - getter_AddRefs(moduleLoaders)); } + // grab the event queue so that we can process events one last time before exiting + nsCOMPtr currentQ; + { + nsCOMPtr eventQService = + do_GetService(kEventQueueServiceCID, &rv); + + if (eventQService) { + eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(currentQ)); + } + } // XPCOM is officially in shutdown mode NOW // Set this only after the observers have been notified as this // will cause servicemanager to become inaccessible. @@ -858,27 +845,6 @@ NS_ShutdownXPCOM(nsIServiceManager* servMgr) // Release the directory service NS_IF_RELEASE(nsDirectoryService::gService); - if (moduleLoaders) { - PRBool more; - nsCOMPtr el; - while (NS_SUCCEEDED(moduleLoaders->HasMoreElements(&more)) && - more) { - moduleLoaders->GetNext(getter_AddRefs(el)); - - // Don't worry about weak-reference observers here: there is - // no reason for weak-ref observers to register for - // xpcom-shutdown-loaders - - nsCOMPtr obs(do_QueryInterface(el)); - if (obs) - (void) obs->Observe(nsnull, - NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID, - nsnull); - } - - moduleLoaders = nsnull; - } - // Shutdown nsLocalFile string conversion NS_ShutdownLocalFile(); #ifdef XP_UNIX