From 969b04ca5eebdcfcd13d282f31808dd5664d58a3 Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Sat, 22 Dec 2001 00:21:46 +0000 Subject: [PATCH] Fix Mac shutdown crash, bug 116128. Ensure that the timer thread dies by using Join(). r=syd, sr=jag git-svn-id: svn://10.0.0.236/trunk@111020 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/threads/TimerThread.cpp | 28 +++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/mozilla/xpcom/threads/TimerThread.cpp b/mozilla/xpcom/threads/TimerThread.cpp index 3f2e7f38c57..e97ad4e09bd 100644 --- a/mozilla/xpcom/threads/TimerThread.cpp +++ b/mozilla/xpcom/threads/TimerThread.cpp @@ -104,20 +104,23 @@ nsresult TimerThread::Shutdown() if (!mThread) return NS_ERROR_NOT_INITIALIZED; - nsAutoLock lock(mLock); + { // lock scope + nsAutoLock lock(mLock); - mProcessing = PR_FALSE; + mProcessing = PR_FALSE; - // notify the cond var so that Run() can return - if (mCondVar && mWaiting) - PR_NotifyCondVar(mCondVar); + // notify the cond var so that Run() can return + if (mCondVar && mWaiting) + PR_NotifyCondVar(mCondVar); - nsTimerImpl *timer; - for (PRInt32 i = mTimers.Count() - 1; i >= 0; i--) { - timer = NS_STATIC_CAST(nsTimerImpl*, mTimers[i]); - RemoveTimerInternal(timer); + nsTimerImpl *timer; + for (PRInt32 i = mTimers.Count() - 1; i >= 0; i--) { + timer = NS_STATIC_CAST(nsTimerImpl*, mTimers[i]); + RemoveTimerInternal(timer); + } } - + + mThread->Join(); // wait for the thread to die return NS_OK; } @@ -135,10 +138,11 @@ NS_IMETHODIMP TimerThread::Run() PRIntervalTime itIsNow = PR_IntervalNow(); #ifdef ACCEPT_WRONG_TIMES - if (itIsNow + kThreeMS > timer->mTimeout - kThreeMS) { + if (itIsNow + kThreeMS > timer->mTimeout - kThreeMS) #else - if (itIsNow >= timer->mTimeout) { + if (itIsNow >= timer->mTimeout) #endif + { RemoveTimerInternal(timer); theTimer = timer; NS_ADDREF(theTimer);