From a95643c63c71bd5637b46baf145f73749b3001e1 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Thu, 15 Aug 2019 17:29:26 +0000 Subject: [PATCH] Bug 1573160 - shutdown newly-spawned threads if we're shutting down; r=mccr8 a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D41551 --HG-- extra : source : 486c1d9d10912074867ea4b255107007224bedf7 extra : intermediate-source : cbf4da0320f6095e61813fa1eafd1b46fdd4716d --- xpcom/threads/nsThreadPool.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xpcom/threads/nsThreadPool.cpp b/xpcom/threads/nsThreadPool.cpp index 7a87cac9390c8..63062e3193003 100644 --- a/xpcom/threads/nsThreadPool.cpp +++ b/xpcom/threads/nsThreadPool.cpp @@ -117,7 +117,9 @@ nsresult nsThreadPool::PutEvent(already_AddRefed aEvent, bool killThread = false; { MutexAutoLock lock(mMutex); - if (mThreads.Count() < (int32_t)mThreadLimit) { + if (mShutdown) { + killThread = true; + } else if (mThreads.Count() < (int32_t)mThreadLimit) { mThreads.AppendObject(thread); } else { killThread = true; // okay, we don't need this thread anymore