diff --git a/mozilla/netwerk/base/src/nsSocketTransportService.cpp b/mozilla/netwerk/base/src/nsSocketTransportService.cpp index c200cdfc792..40c977972e4 100644 --- a/mozilla/netwerk/base/src/nsSocketTransportService.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransportService.cpp @@ -27,6 +27,7 @@ #include "nsAutoLock.h" #include "nsIIOService.h" #include "nsIServiceManager.h" +#include "nsProxiedService.h" #include "nsString.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -68,7 +69,7 @@ nsSocketTransportService::~nsSocketTransportService() mSelectFDSet = nsnull; } - if (mActiveTransportList) { + if (mActiveTransportList) { PR_Free(mActiveTransportList); mActiveTransportList = nsnull; } @@ -155,6 +156,12 @@ nsSocketTransportService::Init(void) } } + // Hold onto the eventQueue service. We do not want any eventqueues to go away + // when we shutdown until we process all remaining transports + + if (NS_SUCCEEDED(rv)) + mEventQueueService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv); + // // Create the transport thread... // @@ -476,8 +483,7 @@ nsSocketTransportService::Run(void) /* Process any pending operations on the mWorkQ... */ rv = ProcessWorkQ(); } - - return NS_OK; + return NS_OK; } @@ -608,8 +614,15 @@ nsSocketTransportService::Shutdown(void) { PRStatus status; nsresult rv = NS_OK; - + int i; + if (mThread) { + // Cancel all remaining transports. + for (i=0; iCancel(NS_BINDING_ABORTED); + } + // // Clear the running flag and wake up the transport thread... // @@ -630,6 +643,10 @@ nsSocketTransportService::Shutdown(void) } NS_RELEASE(mThread); + + for (i=0; iCreateBundle(propertyURL, locale, getter_AddRefs(m_stringBundle)); diff --git a/mozilla/netwerk/base/src/nsSocketTransportService.h b/mozilla/netwerk/base/src/nsSocketTransportService.h index 03a2ee35bd5..c020c893a7c 100644 --- a/mozilla/netwerk/base/src/nsSocketTransportService.h +++ b/mozilla/netwerk/base/src/nsSocketTransportService.h @@ -30,6 +30,7 @@ #include "nsIInputStream.h" #include "nsCOMPtr.h" #include "nsIStringBundle.h" +#include "nsIEventQueueService.h" #if defined(XP_PC) || defined(XP_UNIX) || defined(XP_BEOS) // @@ -94,6 +95,7 @@ protected: PRPollDesc* mSelectFDSet; nsSocketTransport** mActiveTransportList; nsCOMPtr m_stringBundle; + nsCOMPtr mEventQueueService; }; diff --git a/mozilla/xpcom/build/nsXPComInit.cpp b/mozilla/xpcom/build/nsXPComInit.cpp index bd21f910a85..9472c2916c1 100644 --- a/mozilla/xpcom/build/nsXPComInit.cpp +++ b/mozilla/xpcom/build/nsXPComInit.cpp @@ -651,6 +651,16 @@ nsresult NS_COM NS_ShutdownXPCOM(nsIServiceManager* servMgr) } } + // grab the event queue so that we can process events one last time before exiting + nsCOMPtr currentQ; + { + NS_WITH_SERVICE(nsIEventQueueService, eventQService, + 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. @@ -662,6 +672,11 @@ nsresult NS_COM NS_ShutdownXPCOM(nsIServiceManager* servMgr) // Shutdown global servicemanager nsServiceManager::ShutdownGlobalServiceManager(NULL); + + if (currentQ) { + currentQ->ProcessPendingEvents(); + currentQ = 0; + } #ifndef XPCOM_STANDALONE // Release the global case converter