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
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 12b3d42f..fc20bd0 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -900,14 +900,21 @@
// TODO(ahendrickson): This is recorded after the entire SYN_STREAM control
// frame has been received and processed. Move to framer?
response.response_time = base::Time::Now();
+ int rv = OK;
+
if (SpdyHeadersToHttpResponse(headers, &response)) {
GetSSLInfo(&response.ssl_info);
response.request_time = stream->GetRequestTime();
response.vary_data.Init(*stream->GetRequestInfo(), *response.headers);
- stream->OnResponseReceived(response);
+ rv = stream->OnResponseReceived(response);
} else {
+ rv = ERR_INVALID_RESPONSE;
+ }
+
+ if (rv < 0) {
+ DCHECK_NE(rv, ERR_IO_PENDING);
const spdy::SpdyStreamId stream_id = stream->stream_id();
- stream->OnClose(ERR_INVALID_RESPONSE);
+ stream->OnClose(rv);
DeactivateStream(stream_id);
return false;
}