Kill newly-spawned threads if we're shutting down.

This commit is contained in:
Fedor 2019-09-20 13:11:52 +03:00
parent 3ebbfc6e8f
commit be98cb90b7

View File

@ -112,7 +112,9 @@ nsThreadPool::PutEvent(already_AddRefed<nsIRunnable> aEvent, uint32_t aFlags)
bool killThread = false; bool killThread = false;
{ {
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);
if (mThreads.Count() < (int32_t)mThreadLimit) { if (mShutdown) {
killThread = true; // we're in shutdown, kill the thread
} else if (mThreads.Count() < (int32_t)mThreadLimit) {
mThreads.AppendObject(thread); mThreads.AppendObject(thread);
} else { } else {
killThread = true; // okay, we don't need this thread anymore killThread = true; // okay, we don't need this thread anymore