Bug 1381016 - Ensure we process FIN flags on all-padding final frames. r?swu draft
authorNicholas Hurley <hurley@mozilla.com>
Tue, 01 Aug 2017 15:24:44 -0700
changeset 619371 363de666a7773fac82a93728ddb353bdd077c2e9
parent 617594 b0e7bb26ad9264fe14b7d38a4bb944bb2a0346d1
child 640369 6f646a67fbd456bf06c28c2d1f6147b6a4c6bfc6
push id71650
push userbmo:hurley@mozilla.com
push dateTue, 01 Aug 2017 22:26:42 +0000
reviewersswu
bugs1381016
milestone56.0a1
Bug 1381016 - Ensure we process FIN flags on all-padding final frames. r?swu MozReview-Commit-ID: JuSGsYsmv4n
netwerk/protocol/http/Http2Session.cpp
--- a/netwerk/protocol/http/Http2Session.cpp
+++ b/netwerk/protocol/http/Http2Session.cpp
@@ -3221,17 +3221,20 @@ Http2Session::WriteSegmentsAgain(nsAHttp
   if (mDownstreamState == DISCARDING_DATA_FRAME ||
       mDownstreamState == DISCARDING_DATA_FRAME_PADDING) {
     char trash[4096];
     uint32_t discardCount = std::min(mInputFrameDataSize - mInputFrameDataRead,
                                      4096U);
     LOG3(("Http2Session::WriteSegments %p trying to discard %d bytes of data",
           this, discardCount));
 
-    if (!discardCount) {
+    if (!discardCount && mDownstreamState == DISCARDING_DATA_FRAME) {
+      // Only do this short-cirtuit if we're not discarding a pure padding
+      // frame, as we need to potentially handle the stream FIN in those cases.
+      // See bug 1381016 comment 36 for more details.
       ResetDownstreamState();
       Unused << ResumeRecv();
       return NS_BASE_STREAM_WOULD_BLOCK;
     }
 
     rv = NetworkRead(writer, trash, discardCount, countWritten);
 
     if (NS_FAILED(rv)) {