Bug 449885 - "Threadpool calls shutdown on its threads twice when shutdown called on the threadpool". r=bsmedberg.
authorBen Turner <bent.mozilla@gmail.com>
Thu, 14 Aug 2008 12:04:31 -0700
changeset 16684 23d4c8a2b71d3c919ed8b4edade80cdfa3edea8f
parent 16683 1b00cb58ed699ca72c4bd0cdd130bca5b314a51c
child 16685 6083213f3de26a0d325c0348b4589655173486a1
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs449885
milestone1.9.1a2pre
Bug 449885 - "Threadpool calls shutdown on its threads twice when shutdown called on the threadpool". r=bsmedberg.
xpcom/threads/nsThreadPool.cpp
--- 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