Bug 1371728 - Don't honor the idle period during shutdown. r=smaug, a=jcristau FIREFOX_55_0b2_BUILD1 FIREFOX_55_0b2_RELEASE
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 13 Jun 2017 12:22:06 -0400
changeset 411621 803f16362c14a488b1923b184859f8265f63731f
parent 411620 99a32c88cdc3779d2190a58ea2ae0e275d8d4471
child 411622 9e20e9175de1bbcea33b9b67be64d3734156bae4
push id7419
push userryanvm@gmail.com
push dateThu, 15 Jun 2017 13:34:56 +0000
treeherdermozilla-beta@803f16362c14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, jcristau
bugs1371728
milestone55.0
Bug 1371728 - Don't honor the idle period during shutdown. r=smaug, a=jcristau
xpcom/threads/nsThread.cpp
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -1036,16 +1036,28 @@ nsThread::Shutdown()
   ShutdownComplete(context);
 
   return NS_OK;
 }
 
 TimeStamp
 nsThread::GetIdleDeadline()
 {
+  // If we are shutting down, we won't honor the idle period, and we will
+  // always process idle runnables.  This will ensure that the idle queue
+  // gets exhausted at shutdown time to prevent intermittently leaking
+  // some runnables inside that queue and even worse potentially leaving
+  // some important cleanup work unfinished.
+  // Note that we need to check both of these conditions since ShuttingDown()
+  // will never return true on the main thread, where gXPCOMThreadsShutDown
+  // performs a similar function.
+  if (gXPCOMThreadsShutDown || ShuttingDown()) {
+    return TimeStamp::Now();
+  }
+
   TimeStamp idleDeadline;
   {
     // Releasing the lock temporarily since getting the idle period
     // might need to lock the timer thread. Unlocking here might make
     // us receive an event on the main queue, but we've committed to
     // run an idle event anyhow.
     MutexAutoUnlock unlock(mLock);
     mIdlePeriod->GetIdlePeriodHint(&idleDeadline);