Bug 633457 - "Firefox hangs at startup" (r=bent, a=hardblocker)
authorGinn Chen <ginn.chen@oracle.com>
Fri, 11 Feb 2011 20:49:00 -0800
changeset 62864 afba7603a946119551165dae195e7f1be9f75799
parent 62863 6bad6cd2dded7db460b76377552e359d2a4eefb9
child 62865 97625b507157c24adef2f2ac31692c0a2a5bb718
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersbent, hardblocker
bugs633457
milestone2.0b12pre
Bug 633457 - "Firefox hangs at startup" (r=bent, a=hardblocker)
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -3280,16 +3280,17 @@ nsCycleCollector_DEBUG_wasFreed(nsISuppo
 class nsCycleCollectorRunner : public nsRunnable
 {
     nsCycleCollector *mCollector;
     nsICycleCollectorListener *mListener;
     Mutex mLock;
     CondVar mRequest;
     CondVar mReply;
     PRBool mRunning;
+    PRBool mShutdown;
     PRBool mCollected;
     PRBool mJSGCHasRun;
 
 public:
     NS_IMETHOD Run()
     {
 #ifdef XP_WIN
         TlsSetValue(gTLSThreadIDIndex,
@@ -3300,16 +3301,19 @@ public:
         gCycleCollectorThread = PR_GetCurrentThread();
 #endif
 
         NS_ASSERTION(NS_IsCycleCollectorThread() && !NS_IsMainThread(),
                      "Wrong thread!");
 
         MutexAutoLock autoLock(mLock);
 
+        if (mShutdown)
+            return NS_OK;
+
         mRunning = PR_TRUE;
 
         while (1) {
             mRequest.Wait();
 
             if (!mRunning) {
                 mReply.Notify();
                 return NS_OK;
@@ -3325,16 +3329,17 @@ public:
 
     nsCycleCollectorRunner(nsCycleCollector *collector)
         : mCollector(collector),
           mListener(nsnull),
           mLock("cycle collector lock"),
           mRequest(mLock, "cycle collector request condvar"),
           mReply(mLock, "cycle collector reply condvar"),
           mRunning(PR_FALSE),
+          mShutdown(PR_FALSE),
           mCollected(PR_FALSE),
           mJSGCHasRun(PR_FALSE)
     {
         NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
     }
 
     PRUint32 Collect(nsICycleCollectorListener* aListener)
     {
@@ -3369,16 +3374,18 @@ public:
     }
 
     void Shutdown()
     {
         NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
         MutexAutoLock autoLock(mLock);
 
+        mShutdown = PR_TRUE;
+
         if (!mRunning)
             return;
 
         mRunning = PR_FALSE;
         mRequest.Notify();
         mReply.Wait();
     }