Commit 4f517124 authored by akalin@chromium.org's avatar akalin@chromium.org

[SPDY] Count closed-stream DATA frames for session flow control

This ensures that both sides' flow control states stay in sync even if one side resets a stream.

BUG=269873
R=rch@chromium.org

Review URL: https://codereview.chromium.org/22610006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217107 0039d316-1c4b-4281-b951-d872f2087c98
parent bafd7396
......@@ -1806,6 +1806,26 @@ void SpdySession::OnStreamFrameData(SpdyStreamId stream_id,
base::Bind(&NetLogSpdyDataCallback, stream_id, len, fin));
}
// Build the buffer as early as possible so that we go through the
// session flow control checks and update
// |unacked_recv_window_bytes_| properly even when the stream is
// inactive (since the other side has still reduced its session send
// window).
scoped_ptr<SpdyBuffer> buffer;
if (data) {
DCHECK_GT(len, 0u);
buffer.reset(new SpdyBuffer(data, len));
if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) {
DecreaseRecvWindowSize(static_cast<int32>(len));
buffer->AddConsumeCallback(
base::Bind(&SpdySession::OnReadBufferConsumed,
weak_factory_.GetWeakPtr()));
}
} else {
DCHECK_EQ(len, 0u);
}
ActiveStreamMap::iterator it = active_streams_.find(stream_id);
// By the time data comes in, the stream may already be inactive.
......@@ -1822,20 +1842,6 @@ void SpdySession::OnStreamFrameData(SpdyStreamId stream_id,
return;
}
scoped_ptr<SpdyBuffer> buffer;
if (data) {
DCHECK_GT(len, 0u);
buffer.reset(new SpdyBuffer(data, len));
if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) {
DecreaseRecvWindowSize(static_cast<int32>(len));
buffer->AddConsumeCallback(
base::Bind(&SpdySession::OnReadBufferConsumed,
weak_factory_.GetWeakPtr()));
}
} else {
DCHECK_EQ(len, 0u);
}
stream->OnDataReceived(buffer.Pass());
}
......
......@@ -3178,7 +3178,8 @@ TEST_P(SpdySessionTest, AdjustSendWindowSize) {
}
// Incoming data for an inactive stream should not cause the session
// receive window size to decrease.
// receive window size to decrease, but it should cause the unacked
// bytes to increase.
TEST_P(SpdySessionTest, SessionFlowControlInactiveStream) {
if (GetParam() < kProtoSPDY31)
return;
......@@ -3210,7 +3211,7 @@ TEST_P(SpdySessionTest, SessionFlowControlInactiveStream) {
data.RunFor(1);
EXPECT_EQ(kSpdySessionInitialWindowSize, session->session_recv_window_size_);
EXPECT_EQ(0, session->session_unacked_recv_window_bytes_);
EXPECT_EQ(kUploadDataSize, session->session_unacked_recv_window_bytes_);
data.RunFor(1);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment