Fixes dropped socket transport during shutdown. The xpcom fix causes the UI event queue to be processed one final time after services shutdown. The socket transport fix forces all remaining active transports to be canceled, then released. r= waterson@netscape.com && darin@netscape.com a=mscott@netscape.com. b=63565

git-svn-id: svn://10.0.0.236/trunk@84645 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dougt%netscape.com
2001-01-09 05:44:47 +00:00
parent 61db3f1d6c
commit 9145344cfc
3 changed files with 41 additions and 6 deletions

View File

@@ -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; i<mSelectFDSetCount; i++) {
if (mActiveTransportList[i])
mActiveTransportList[i]->Cancel(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; i<mSelectFDSetCount; i++)
NS_IF_RELEASE(mActiveTransportList[i]);
} else {
rv = NS_ERROR_FAILURE;
}
@@ -675,8 +692,9 @@ nsSocketTransportService::GetNeckoStringByName (const char *aName, PRUnichar **a
if (!m_stringBundle) {
char* propertyURL = NECKO_MSGS_URL;
NS_WITH_SERVICE(nsIStringBundleService, sBundleService, kStringBundleServiceCID, &res);
// make sure that we get this service on the UI thread.
NS_WITH_PROXIED_SERVICE(nsIStringBundleService, sBundleService, kStringBundleServiceCID,
NS_UI_THREAD_EVENTQ, &res);
if (NS_SUCCEEDED (res) && (nsnull != sBundleService)) {
nsILocale *locale = nsnull;
res = sBundleService->CreateBundle(propertyURL, locale, getter_AddRefs(m_stringBundle));

View File

@@ -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<nsIStringBundle> m_stringBundle;
nsCOMPtr<nsIEventQueueService> mEventQueueService;
};

View File

@@ -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 <nsIEventQueue> 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