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
1 changed files with 3 additions and 1 deletions

View File

@ -112,7 +112,9 @@ nsThreadPool::PutEvent(already_AddRefed<nsIRunnable> aEvent, uint32_t aFlags)
bool killThread = false;
{
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);
} else {
killThread = true; // okay, we don't need this thread anymore