bug 1035075 - orderly shutdown of pac thread r=sworkman
☠☠ backed out by e2650b0b07d6 ☠ ☠
authorPatrick McManus <mcmanus@ducksong.com>
Fri, 18 Jul 2014 16:44:24 -0400
changeset 217018 ece3f69eb1b1b865347bfc115ee93e969192d64c
parent 217017 8ada22bb1f40543b63d3a216e29b36c924ad8b58
child 217019 e7f38a75b454b87a5eac74368240009673e51563
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssworkman
bugs1035075
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1035075 - orderly shutdown of pac thread r=sworkman
netwerk/base/src/nsPACMan.cpp
--- a/netwerk/base/src/nsPACMan.cpp
+++ b/netwerk/base/src/nsPACMan.cpp
@@ -282,16 +282,24 @@ nsPACMan::~nsPACMan()
 
 void
 nsPACMan::Shutdown()
 {
   NS_ABORT_IF_FALSE(NS_IsMainThread(), "pacman must be shutdown on main thread");
   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
 nsPACMan::AsyncGetProxyForURI(nsIURI *uri, nsPACManCallback *callback,
                               bool mainThreadResponse)
 {
   NS_ABORT_IF_FALSE(NS_IsMainThread(), "wrong thread");
   if (mShutdown)
@@ -489,21 +497,22 @@ nsPACMan::CancelPendingQ(nsresult status
 }
 
 void
 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
 bool
 nsPACMan::ProcessPending()
 {
   if (mPendingQ.isEmpty())
     return false;