Bug 1644239, r=dragana, a=jcristau
authorKershaw Chang <kershaw@mozilla.com>
Tue, 23 Jun 2020 07:51:25 +0000
changeset 600877 aecfc014ba0c7e748cc32423c0ee94e62d5acfea
parent 600876 2c4b83fa228b35762d6c17179c8e39f28c7eeba8
child 600878 2921a9fe2aeb34ee2ea604efc54dc8e10cb77061
push id2364
push userjcristau@mozilla.com
push dateThu, 25 Jun 2020 15:29:58 +0000
treeherdermozilla-release@52486654c09a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdragana, jcristau
bugs1644239
milestone78.0
Bug 1644239, r=dragana, a=jcristau 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;