Bug 1644239, r=dragana
authorKershaw Chang <kershaw@mozilla.com>
Tue, 23 Jun 2020 07:51:25 +0000
changeset 600834 69e5de33bd0797d51b019982741eb927920dd471
parent 600833 a40b3c017a19624cdbe7e42b6129a712111f26cb
child 600835 ce1a126dcf105e348ab891cf285a7ca73b295dcb
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdragana
bugs1644239
milestone79.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 1644239, r=dragana Differential Revision: https://phabricator.services.mozilla.com/D80365
netwerk/protocol/http/Http2Session.cpp
--- a/netwerk/protocol/http/Http2Session.cpp
+++ b/netwerk/protocol/http/Http2Session.cpp
@@ -2045,37 +2045,44 @@ nsresult Http2Session::RecvPushPromise(H
     // handler to create any URIs, this will work just fine here. Don't try this
     // at home, though, kids. I'm a trained professional.
     if (NS_SUCCEEDED(Http2Stream::MakeOriginURL(spec, pushedURL))) {
       LOG3(("Http2Session::RecvPushPromise %p check disk cache for entry",
             self));
       mozilla::OriginAttributes oa;
       pushedWeak->GetOriginAttributes(&oa);
       RefPtr<Http2Session> session = self;
-      auto callback = [session, promisedID](bool aAccepted) {
+      auto cachePushCheckCallback = [session, promisedID](bool aAccepted) {
         MOZ_ASSERT(OnSocketThread());
 
         if (!aAccepted) {
           session->CleanupStream(promisedID, NS_ERROR_FAILURE,
                                  Http2Session::REFUSED_STREAM_ERROR);
         }
       };
       RefPtr<CachePushChecker> checker = new CachePushChecker(
           pushedURL, oa,
           static_cast<Http2PushedStream*>(pushedWeak.get())->GetRequestString(),
-          std::move(callback));
+          std::move(cachePushCheckCallback));
       if (NS_FAILED(checker->DoCheck())) {
         LOG3(
             ("Http2Session::RecvPushPromise %p failed to open cache entry for "
              "push check",
              self));
       }
     }
   }
 
+  if (!pushedWeak) {
+    // We have an up to date entry in our cache, so the stream was closed
+    // and released in the cachePushCheckCallback above.
+    self->ResetDownstreamState();
+    return NS_OK;
+  }
+
   pushedWeak->SetHTTPState(Http2Stream::RESERVED_BY_REMOTE);
   static_assert(Http2Stream::kWorstPriority >= 0,
                 "kWorstPriority out of range");
   uint32_t priorityDependency = pushedWeak->PriorityDependency();
   uint8_t priorityWeight = pushedWeak->PriorityWeight();
   self->SendPriorityFrame(promisedID, priorityDependency, priorityWeight);
   self->ResetDownstreamState();
   return NS_OK;