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

This commit is contained in:
Nathan Froyd 2019-09-04 17:55:04 +02:00 committed by Roy Tam
commit f40a82f098

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