bug 1124717 - 1/4 h2/spdy fix spin when queuing post/put request over concurrent limit r=hurley draft
authorPatrick McManus <mcmanus@ducksong.com>
Fri, 23 Jan 2015 11:22:22 -0500
changeset 239225 4761861c990084c7e986ac0df7828884cbae6b53
parent 239224 780d7bb5eb822d16e34233005dd71fce07a0586c
child 239226 48a86b800b56c2e22b5260a6d94edd475b694f30
push id489
push usermcmanus@ducksong.com
push dateTue, 27 Jan 2015 01:44:53 +0000
reviewershurley
bugs1124717
milestone38.0a1
bug 1124717 - 1/4 h2/spdy fix spin when queuing post/put request over concurrent limit r=hurley
netwerk/protocol/http/Http2Stream.cpp
netwerk/protocol/http/SpdyStream31.cpp
--- a/netwerk/protocol/http/Http2Stream.cpp
+++ b/netwerk/protocol/http/Http2Stream.cpp
@@ -179,21 +179,20 @@ Http2Stream::ReadSegments(nsAHttpSegment
       uint32_t wasted = 0;
       mSegmentReader = reader;
       OnReadSegment("", 0, &wasted);
       mSegmentReader = nullptr;
     }
 
     // If the sending flow control window is open (!mBlockedOnRwin) then
     // continue sending the request
-    if (!mBlockedOnRwin && mUpstreamState != GENERATING_HEADERS &&
+    if (!mBlockedOnRwin && mOpenGenerated &&
         !mTxInlineFrameUsed && NS_SUCCEEDED(rv) && (!*countRead)) {
       MOZ_ASSERT(!mQueued);
       MOZ_ASSERT(mRequestHeadersDone);
-      MOZ_ASSERT(mOpenGenerated);
       LOG3(("Http2Stream::ReadSegments %p 0x%X: Sending request data complete, "
             "mUpstreamState=%x\n",this, mStreamID, mUpstreamState));
       if (mSentFin) {
         ChangeState(UPSTREAM_COMPLETE);
       } else {
         GenerateDataFrameHeader(0, true);
         ChangeState(SENDING_FIN_STREAM);
         mSession->TransactionHasDataToWrite(this);
@@ -1229,17 +1228,17 @@ Http2Stream::OnReadSegment(const char *b
       if (NS_FAILED(rv = ParseHttpRequestHeaders(buf, count, countRead))) {
         return rv;
       }
     }
 
     if (mRequestHeadersDone && !mOpenGenerated) {
       if (!mSession->TryToActivate(this)) {
         LOG3(("Http2Stream::OnReadSegment %p cannot activate now. queued.\n", this));
-        return NS_OK;
+        return *countRead ? NS_OK : NS_BASE_STREAM_WOULD_BLOCK;
       }
       if (NS_FAILED(rv = GenerateOpen())) {
         return rv;
       }
    }
 
     LOG3(("ParseHttpRequestHeaders %p used %d of %d. "
           "requestheadersdone = %d mOpenGenerated = %d\n",
--- a/netwerk/protocol/http/SpdyStream31.cpp
+++ b/netwerk/protocol/http/SpdyStream31.cpp
@@ -155,17 +155,17 @@ SpdyStream31::ReadSegments(nsAHttpSegmen
       uint32_t wasted = 0;
       mSegmentReader = reader;
       OnReadSegment("", 0, &wasted);
       mSegmentReader = nullptr;
     }
 
     // If the sending flow control window is open (!mBlockedOnRwin) then
     // continue sending the request
-    if (!mBlockedOnRwin && mUpstreamState != GENERATING_SYN_STREAM &&
+    if (!mBlockedOnRwin && mSynFrameGenerated &&
         !mTxInlineFrameUsed && NS_SUCCEEDED(rv) && (!*countRead)) {
       LOG3(("SpdyStream31::ReadSegments %p 0x%X: Sending request data complete, "
             "mUpstreamState=%x finondata=%d",this, mStreamID,
             mUpstreamState, mSentFinOnData));
       if (mSentFinOnData) {
         ChangeState(UPSTREAM_COMPLETE);
       } else {
         GenerateDataFrameHeader(0, true);
@@ -1486,17 +1486,17 @@ SpdyStream31::OnReadSegment(const char *
       if (NS_FAILED(rv = ParseHttpRequestHeaders(buf, count, countRead))) {
         return rv;
       }
     }
 
     if (mRequestHeadersDone && !mSynFrameGenerated) {
       if (!mSession->TryToActivate(this)) {
         LOG3(("SpdyStream31::OnReadSegment %p cannot activate now. queued.\n", this));
-        return NS_OK;
+        return *countRead ? NS_OK : NS_BASE_STREAM_WOULD_BLOCK;
       }
       if (NS_FAILED(rv = GenerateSynFrame())) {
         return rv;
       }
     }
 
     LOG3(("ParseHttpRequestHeaders %p used %d of %d. "
           "requestheadersdone = %d mSynFrameGenerated = %d\n",