Bug 1397880 - Cancel tailing timer during shutdown. r?nwgh draft
authorShih-Chiang Chien <schien@mozilla.com>
Fri, 08 Sep 2017 12:05:41 +0800
changeset 662840 f3230cbb6bc0407e42b69279f5977127026df05a
parent 661103 b4c1ad9565ee9d00d96501c4a83083daf25c1413
child 730985 c0cee19e88aff0664030766b0887b71680365f67
push id79205
push userbmo:schien@mozilla.com
push dateTue, 12 Sep 2017 05:42:46 +0000
reviewersnwgh
bugs1397880
milestone57.0a1
Bug 1397880 - Cancel tailing timer during shutdown. r?nwgh 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
@@ -375,16 +375,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)));