summaryrefslogtreecommitdiffstats
path: root/net/spdy
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-12 22:54:39 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-12 22:54:39 +0000
commit4f517124236acd19b08cd7a79b145b834e37488d (patch)
tree0e004aacfc4db8e10708d5817e3971eb8bc223ea /net/spdy
parentbafd73967db9327c58fabfa25c547700871acd08 (diff)
downloadchromium_src-4f517124236acd19b08cd7a79b145b834e37488d.zip
chromium_src-4f517124236acd19b08cd7a79b145b834e37488d.tar.gz
chromium_src-4f517124236acd19b08cd7a79b145b834e37488d.tar.bz2
[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
Diffstat (limited to 'net/spdy')
-rw-r--r--net/spdy/spdy_session.cc34
-rw-r--r--net/spdy/spdy_session_unittest.cc5
2 files changed, 23 insertions, 16 deletions
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index db47549..baef195 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -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());
}
diff --git a/net/spdy/spdy_session_unittest.cc b/net/spdy/spdy_session_unittest.cc
index 6388bf8..f0d448c 100644
--- a/net/spdy/spdy_session_unittest.cc
+++ b/net/spdy/spdy_session_unittest.cc
@@ -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);
}