Bug 845190 - Prevent nsStreamTransportService from re-initializing. r=biesi

This commit is contained in:
David Rajchenbach-Teller 2013-06-10 11:01:59 -04:00
parent 5f88c081a4
commit 4595e8879c
2 changed files with 14 additions and 1 deletions

View File

@ -430,6 +430,8 @@ nsOutputStreamTransport::IsNonBlocking(bool *result)
// nsStreamTransportService
//-----------------------------------------------------------------------------
bool nsStreamTransportService::sHasBeenShutdown = false;
nsStreamTransportService::~nsStreamTransportService()
{
NS_ASSERTION(!mPool, "thread pool wasn't shutdown");
@ -438,6 +440,11 @@ nsStreamTransportService::~nsStreamTransportService()
nsresult
nsStreamTransportService::Init()
{
if (sHasBeenShutdown) {
// Prevent any attempt at resurrection
// (see bug 845190)
return NS_ERROR_NOT_AVAILABLE;
}
mPool = do_CreateInstance(NS_THREADPOOL_CONTRACTID);
NS_ENSURE_STATE(mPool);
@ -508,7 +515,7 @@ nsStreamTransportService::Observe(nsISupports *subject, const char *topic,
const PRUnichar *data)
{
NS_ASSERTION(strcmp(topic, "xpcom-shutdown-threads") == 0, "oops");
sHasBeenShutdown = true;
if (mPool) {
mPool->Shutdown();
mPool = nullptr;

View File

@ -27,4 +27,10 @@ private:
~nsStreamTransportService();
nsCOMPtr<nsIThreadPool> mPool;
/**
* |true| if we have shutdown once already, in which
* case we should reject any attempt to resurrect.
*/
static bool sHasBeenShutdown;
};