Bug 449885 - "Threadpool calls shutdown on its threads twice when shutdown called on the threadpool". r=bsmedberg.
--- a/xpcom/threads/nsThreadPool.cpp
+++ b/xpcom/threads/nsThreadPool.cpp
@@ -274,26 +274,26 @@ nsThreadPool::Shutdown()
nsCOMArray<nsIThread> threads;
nsCOMPtr<nsIThreadPoolListener> listener;
{
nsAutoMonitor mon(mEvents.Monitor());
mShutdown = PR_TRUE;
mon.NotifyAll();
threads.AppendObjects(mThreads);
+ mThreads.Clear();
// Swap in a null listener so that we release the listener at the end of
// this method. The listener will be kept alive as long as the other threads
// that were created when it was set.
mListener.swap(listener);
}
// It's important that we shutdown the threads while outside the event queue
- // monitor. Otherwise, we could end up dead-locking. The threads will take
- // care of removing themselves from mThreads as they exit.
+ // monitor. Otherwise, we could end up dead-locking.
for (PRInt32 i = 0; i < threads.Count(); ++i)
threads[i]->Shutdown();
return NS_OK;
}
NS_IMETHODIMP