Bug 1397880 - Cancel tailing timer during shutdown. r=nwgh,valentin
authorShih-Chiang Chien <schien@mozilla.com>
Fri, 08 Sep 2017 12:05:41 +0800
changeset 429690 269426fcc3f39673ae0b4aa167ac00d8534542ca
parent 429689 817a2c4234121c4fabf35922c170503f70e46b3f
child 429691 327f2a97631d24229fc5cb5f07ae9aa8a9d29dd0
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnwgh, valentin
bugs1397880
milestone57.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 1397880 - Cancel tailing timer during shutdown. r=nwgh,valentin RequestContextService will cancel all the blocked tail requests during xpcom-shutdown. However, the timer for unblocking tail request might be already running. RequestContext need to cancel the timer when all blocked tail request is canceled for that context. MozReview-Commit-ID: 1Nbzu2a788w
netwerk/base/RequestContextService.cpp
--- a/netwerk/base/RequestContextService.cpp
+++ b/netwerk/base/RequestContextService.cpp
@@ -380,16 +380,27 @@ RequestContext::CancelTailedRequest(nsIR
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   bool removed = mTailQueue.RemoveElement(aRequest);
 
   LOG(("RequestContext::CancelTailedRequest %p req=%p removed=%d",
        this, aRequest, removed));
 
+  // Stop untail timer if all tail requests are canceled.
+  if (removed && mTailQueue.IsEmpty()) {
+    if (mUntailTimer) {
+      mUntailTimer->Cancel();
+      mUntailTimer = nullptr;
+    }
+
+    // Must drop to stop tailing requests
+    mUntailAt = TimeStamp();
+  }
+
   return NS_OK;
 }
 
 void
 RequestContext::ProcessTailQueue(nsresult aResult)
 {
   LOG(("RequestContext::ProcessTailQueue this=%p, queued=%zu, rv=%" PRIx32,
        this, mTailQueue.Length(), static_cast<uint32_t>(aResult)));