mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 845190 - Prevent nsStreamTransportService from re-initializing. r=biesi
This commit is contained in:
parent
db0da677ba
commit
cc42021837
@ -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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user