diff --git a/netwerk/base/src/nsStreamTransportService.cpp b/netwerk/base/src/nsStreamTransportService.cpp index 817aed84b74..bbe17144616 100644 --- a/netwerk/base/src/nsStreamTransportService.cpp +++ b/netwerk/base/src/nsStreamTransportService.cpp @@ -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; diff --git a/netwerk/base/src/nsStreamTransportService.h b/netwerk/base/src/nsStreamTransportService.h index 0b01a8bd4d2..383a3caa79f 100644 --- a/netwerk/base/src/nsStreamTransportService.h +++ b/netwerk/base/src/nsStreamTransportService.h @@ -27,4 +27,10 @@ private: ~nsStreamTransportService(); nsCOMPtr mPool; + + /** + * |true| if we have shutdown once already, in which + * case we should reject any attempt to resurrect. + */ + static bool sHasBeenShutdown; };