summaryrefslogtreecommitdiffstats
path: root/net/spdy/spdy_stream.cc
diff options
context:
space:
mode:
authormbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 22:25:43 +0000
committermbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 22:25:43 +0000
commita5566f970e60a97a9129af7a828d562e70176d87 (patch)
tree9e9dfe1cdfa8f0cedb8e05b6c9b6484e3273c5c0 /net/spdy/spdy_stream.cc
parentf93be30de128f68037f8eef0dd644df809b6d325 (diff)
downloadchromium_src-a5566f970e60a97a9129af7a828d562e70176d87.zip
chromium_src-a5566f970e60a97a9129af7a828d562e70176d87.tar.gz
chromium_src-a5566f970e60a97a9129af7a828d562e70176d87.tar.bz2
Fix SPDY crash where we receive an early SYN_REPLY.
Added a test case which simulates this by doing a POST and scheduling the SYN_REPLY to arrive before we've finished sending. Also improved the error checking in SpdyStream a bit. BUG=43133 TEST=SpdyNetworkTransactionTest.PostWithEarlySynReply Review URL: http://codereview.chromium.org/1931003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46505 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy/spdy_stream.cc')
-rw-r--r--net/spdy/spdy_stream.cc25
1 files changed, 19 insertions, 6 deletions
diff --git a/net/spdy/spdy_stream.cc b/net/spdy/spdy_stream.cc
index 678b0c4..022ccd2 100644
--- a/net/spdy/spdy_stream.cc
+++ b/net/spdy/spdy_stream.cc
@@ -44,8 +44,10 @@ SpdyStream::~SpdyStream() {
// inactive pending/pushed streams will still have stream_id_ set.
if (stream_id_) {
session_->CancelStream(stream_id_);
- } else if (!response_complete_) {
- NOTREACHED();
+ } else {
+ // When the stream_id_ is 0, we expect that it is because
+ // we've cancelled or closed the stream and set the stream_id to 0.
+ DCHECK(response_complete_);
}
}
@@ -191,7 +193,9 @@ void SpdyStream::Cancel() {
session_->CancelStream(stream_id_);
}
-void SpdyStream::OnResponseReceived(const HttpResponseInfo& response) {
+int SpdyStream::OnResponseReceived(const HttpResponseInfo& response) {
+ int rv = OK;
+
metrics_.StartStream();
CHECK(!response_->headers);
@@ -213,13 +217,16 @@ void SpdyStream::OnResponseReceived(const HttpResponseInfo& response) {
// client requests an X-Associated-Content piece of content prior
// to when the server push happens.
} else {
- NOTREACHED();
+ // We're not expecting a response while in this state. Error!
+ rv = ERR_SPDY_PROTOCOL_ERROR;
}
- int rv = DoLoop(OK);
+ rv = DoLoop(rv);
if (user_callback_)
DoCallback(rv);
+
+ return rv;
}
bool SpdyStream::OnDataReceived(const char* data, int length) {
@@ -276,6 +283,10 @@ void SpdyStream::OnWriteComplete(int status) {
// TODO(mbelshe): Check for cancellation here. If we're cancelled, we
// should discontinue the DoLoop.
+ // It is possible that this stream was closed while we had a write pending.
+ if (response_complete_)
+ return;
+
if (status > 0)
send_bytes_ += status;
@@ -456,6 +467,8 @@ int SpdyStream::DoSendBody() {
// data portion, of course.
io_state_ = STATE_SEND_BODY_COMPLETE;
int buf_len = static_cast<int>(request_body_stream_->buf_len());
+ if (!buf_len)
+ return OK;
return session_->WriteStreamData(stream_id_,
request_body_stream_->buf(),
buf_len);
@@ -499,7 +512,7 @@ int SpdyStream::DoReadBody() {
int SpdyStream::DoReadBodyComplete(int result) {
// TODO(mbelshe): merge SpdyStreamParser with SpdyStream and then this
// makes sense.
- return result;
+ return OK;
}
void SpdyStream::UpdateHistograms() {