Bug 1382845 - We should cancel mNetworkTriggerTimer when we start reading data from the cache. r=michal
authorValentin Gosu <valentin.gosu@gmail.com>
Fri, 21 Jul 2017 01:25:02 +0300
changeset 418717 a4c46cc48c7836ce767ab8897deea0299f61d79c
parent 418716 5df4ba09e140e576b9045e9ee7dc8b53f30d17c4
child 418718 79bc740e42aaeb256202eef44335a563594a7b04
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal
bugs1382845
milestone56.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 1382845 - We should cancel mNetworkTriggerTimer when we start reading data from the cache. r=michal MozReview-Commit-ID: HOnWemy2YCY
netwerk/protocol/http/nsHttpChannel.cpp
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -5010,16 +5010,23 @@ nsHttpChannel::ReadFromCache(bool alread
 {
     NS_ENSURE_TRUE(mCacheEntry, NS_ERROR_FAILURE);
     NS_ENSURE_TRUE(mCachedContentIsValid, NS_ERROR_FAILURE);
     NS_ENSURE_TRUE(!mCachePump, NS_OK); // already opened
 
     LOG(("nsHttpChannel::ReadFromCache [this=%p] "
          "Using cached copy of: %s\n", this, mSpec.get()));
 
+    // When racing the cache with the network with a timer, and we get data from
+    // the cache, we should prevent the timer from triggering a network request.
+    if (mNetworkTriggerTimer) {
+        mNetworkTriggerTimer->Cancel();
+        mNetworkTriggerTimer = nullptr;
+    }
+
     if (mRaceCacheWithNetwork) {
         MOZ_ASSERT(mFirstResponseSource != RESPONSE_FROM_CACHE);
         if (mFirstResponseSource == RESPONSE_PENDING) {
             LOG(("First response from cache\n"));
             mFirstResponseSource = RESPONSE_FROM_CACHE;
 
             // Cancel the transaction because we will serve the request from the cache
             CancelNetworkRequest(NS_BINDING_ABORTED);