diff --git a/mozilla/xpcom/components/nsComponentManager.cpp b/mozilla/xpcom/components/nsComponentManager.cpp index 3b6e3bef2e5..f9d6b02fabf 100644 --- a/mozilla/xpcom/components/nsComponentManager.cpp +++ b/mozilla/xpcom/components/nsComponentManager.cpp @@ -1880,14 +1880,21 @@ nsComponentManagerImpl::FreeLibraries(void) nsresult nsComponentManagerImpl::UnloadLibraries(nsIServiceManager *serviceMgr) { + nsresult rv = NS_OK; + PR_EnterMonitor(mMon); PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, ("nsComponentManager: Unloading Libraries.")); + // XXX UnloadAll the loaders + + // UnloadAll the native loader + rv = mNativeComponentLoader->UnloadAll(NS_Timer); + PR_ExitMonitor(mMon); - return NS_OK; + return rv; } //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/xpcom/components/nsNativeComponentLoader.cpp b/mozilla/xpcom/components/nsNativeComponentLoader.cpp index 1cd35148994..2d13ec9087c 100644 --- a/mozilla/xpcom/components/nsNativeComponentLoader.cpp +++ b/mozilla/xpcom/components/nsNativeComponentLoader.cpp @@ -362,28 +362,43 @@ nsFreeLibrary(nsDll *dll, nsIServiceManager *serviceMgr) // an error. dll->MarkForUnload(PR_FALSE); - + PRBool canUnload = PR_FALSE; + // Get the module object nsCOMPtr mobj; /* XXXshaver cheat and use the global component manager */ rv = dll->GetModule(nsComponentManagerImpl::gComponentManager, getter_AddRefs(mobj)); - if (NS_FAILED(rv)) + if (NS_SUCCEEDED(rv)) { - PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, - ("nsComponentManager: Cannot get module object for %s", dll->GetNativePath())); - return rv; + rv = mobj->CanUnload(nsComponentManagerImpl::gComponentManager, &canUnload); + if (NS_FAILED(rv)) + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: nsIModule::CanUnload() returned error for %s.", + dll->GetNativePath())); + return rv; + } } +#ifndef OBSOLETE_MODULE_LOADING + else + { + // Try the old method of module unloading + nsCanUnloadProc proc = (nsCanUnloadProc)dll->FindSymbol("NSCanUnload"); + if (proc) + { + canUnload = proc(serviceMgr); + } + else + { + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, + ("nsComponentManager: Unload cant get nsIModule or CanUnload for %s", + dll->GetNativePath())); + return rv; + } + } +#endif /* OBSOLETE_MODULE_LOADING */ - PRBool canUnload; - rv = mobj->CanUnload(nsComponentManagerImpl::gComponentManager, &canUnload); - if (NS_FAILED(rv)) - { - PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, - ("nsComponentManager: nsIModule::CanUnload() returned error for %s.", dll->GetNativePath())); - return rv; - } - if (canUnload) { if (dllMarkedForUnload) @@ -852,9 +867,10 @@ nsNativeComponentLoader::OnRegister(const nsIID &aCID, const char *aType, nsresult nsNativeComponentLoader::UnloadAll(PRInt32 aWhen) { -#ifdef DEBUG_shaver - fprintf(stderr, "nNCL:UnloadAll(%d)\n", aWhen); -#endif + PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsNativeComponentLoader: Unloading....")); + + // Cycle through the dlls checking to see if they want to be unloaded + mDllStore->Enumerate(nsFreeLibraryEnum, NULL); return NS_OK; }