From d9fd068b46022f321ed2cc654393ad42597566ff Mon Sep 17 00:00:00 2001 From: Patrick McManus Date: Fri, 18 Jul 2014 16:44:24 -0400 Subject: [PATCH] bug 1035075 - orderly shutdown of pac thread r=sworkman --- netwerk/base/src/nsPACMan.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/netwerk/base/src/nsPACMan.cpp b/netwerk/base/src/nsPACMan.cpp index 6dff4fad555..46359cdfc7f 100644 --- a/netwerk/base/src/nsPACMan.cpp +++ b/netwerk/base/src/nsPACMan.cpp @@ -287,6 +287,14 @@ nsPACMan::Shutdown() CancelExistingLoad(); mShutdown = true; PostCancelPendingQ(NS_ERROR_ABORT); + + // this can't return until pac thread is joined + LOG(("nsPACMan::Shutdown Thread shutdown start %p", mPACThread.get())); + if (mPACThread) { + mPACThread->Shutdown(); + mPACThread = nullptr; + } + LOG(("nsPACMan::Shutdown Thread shutdown finish")); } nsresult @@ -494,11 +502,12 @@ nsPACMan::ProcessPendingQ() NS_ABORT_IF_FALSE(!NS_IsMainThread(), "wrong thread"); while (ProcessPending()); - // do GC while the thread has nothing pending - mPAC.GC(); - - if (mShutdown) + if (mShutdown) { mPAC.Shutdown(); + } else { + // do GC while the thread has nothing pending + mPAC.GC(); + } } // returns true if progress was made by shortening the queue