Bug 1396307 - Set mCacheAsyncOpenCalled back to flase when AsyncOpenURI fails r=michal draft
authorValentin Gosu <valentin.gosu@gmail.com>
Thu, 14 Sep 2017 22:21:49 +0200
changeset 665025 b0dd35d8dc246edef20c4d6cf220013131366b1e
parent 664992 4ae01e3889b5e1cd3708e9a1273b7e0eb79aca51
child 665187 f4eb8349627f12ccf638f1d42c7c8a0aecb00fe7
push id79903
push uservalentin.gosu@gmail.com
push dateThu, 14 Sep 2017 20:26:47 +0000
reviewersmichal
bugs1396307
milestone57.0a1
Bug 1396307 - Set mCacheAsyncOpenCalled back to flase when AsyncOpenURI fails r=michal MozReview-Commit-ID: VnwI3ERHVt
netwerk/protocol/http/nsHttpChannel.cpp
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -3974,26 +3974,33 @@ nsHttpChannel::OpenCacheEntry(bool isHtt
 
         if (!mCacheOpenDelay) {
             MOZ_ASSERT(NS_IsMainThread(), "Should be called on the main thread");
             mCacheAsyncOpenCalled = true;
             if (mNetworkTriggered) {
                 mRaceCacheWithNetwork = sRCWNEnabled;
             }
             rv = cacheStorage->AsyncOpenURI(openURI, extension, cacheEntryOpenFlags, this);
+            if (NS_FAILED(rv)) {
+                // Drop the flag since the cache open failed
+                mCacheAsyncOpenCalled = false;
+            }
         } else {
             // We pass `this` explicitly as a parameter due to the raw pointer
             // to refcounted object in lambda analysis.
             mCacheOpenFunc = [openURI, extension, cacheEntryOpenFlags, cacheStorage] (nsHttpChannel* self) -> void {
                 MOZ_ASSERT(NS_IsMainThread(), "Should be called on the main thread");
                 self->mCacheAsyncOpenCalled = true;
                 if (self->mNetworkTriggered) {
                     self->mRaceCacheWithNetwork = true;
                 }
-                cacheStorage->AsyncOpenURI(openURI, extension, cacheEntryOpenFlags, self);
+                nsresult rv = cacheStorage->AsyncOpenURI(openURI, extension, cacheEntryOpenFlags, self);
+                if (NS_FAILED(rv)) {
+                    self->mCacheAsyncOpenCalled = false;
+                }
             };
 
             mCacheOpenTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
             // calls nsHttpChannel::Notify after `mCacheOpenDelay` milliseconds
             mCacheOpenTimer->InitWithCallback(this, mCacheOpenDelay, nsITimer::TYPE_ONE_SHOT);
 
         }
         NS_ENSURE_SUCCESS(rv, rv);