Bug 1367810 - Don't race cache with network when CORS preflight is required for a channel r=michal
authorValentin Gosu <valentin.gosu@gmail.com>
Fri, 16 Jun 2017 00:32:00 +0300
changeset 412992 12caabbf2ba860021b1879c5cc9e7ce521aa373e
parent 412991 c83344a415617b997c07104a92f085f476d974b7
child 412993 d220383ec899a25106b913433f8938dbfea96b5f
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
bugs1367810
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 1367810 - Don't race cache with network when CORS preflight is required for a channel r=michal MozReview-Commit-ID: CPyafHsMYoy
netwerk/protocol/http/nsHttpChannel.cpp
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -9161,16 +9161,26 @@ nsHttpChannel::TriggerNetwork(int32_t aT
 nsresult
 nsHttpChannel::MaybeRaceCacheWithNetwork()
 {
     // Don't trigger the network if the load flags say so.
     if (mLoadFlags & (LOAD_ONLY_FROM_CACHE | LOAD_NO_NETWORK_IO)) {
         return NS_OK;
     }
 
+    // We must not race if the channel has a failure status code.
+    if (NS_FAILED(mStatus)) {
+        return NS_OK;
+    }
+
+    // If a CORS Preflight is required we must not race.
+    if (mRequireCORSPreflight && !mIsCorsPreflightDone) {
+        return NS_OK;
+    }
+
     uint32_t threshold = mCacheOpenWithPriority ? sRCWNQueueSizePriority
                                                 : sRCWNQueueSizeNormal;
     // No need to trigger to trigger the racing, since most likely the cache
     // will be faster.
     if (mCacheQueueSizeWhenOpen < threshold) {
         return NS_OK;
     }