diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/spdy/spdy_network_transaction_unittest.cc | 29 | ||||
-rw-r--r-- | net/spdy/spdy_session.cc | 4 |
2 files changed, 33 insertions, 0 deletions
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index 12625b2..a115fd6 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc @@ -288,6 +288,12 @@ static const unsigned char kPostBodyFrame[] = { 'h', 'e', 'l', 'l', 'o', '!', // "hello" }; +static const unsigned char kGoAway[] = { + 0x80, 0x01, 0x00, 0x07, // header + 0x00, 0x00, 0x00, 0x04, // flags, len + 0x00, 0x00, 0x00, 0x00, // last-accepted-stream-id +}; + // Adds headers and values to a map. // |extra_headers| is an array of { name, value } pairs, arranged as strings // where the even entries are the header names, and the odd entries are the @@ -2707,4 +2713,27 @@ TEST_F(SpdyNetworkTransactionTest, SettingsPlayback) { } } +TEST_F(SpdyNetworkTransactionTest, GoAwayWithActiveStream) { + MockWrite writes[] = { + MockWrite(true, reinterpret_cast<const char*>(kGetSyn), + arraysize(kGetSyn)), + }; + + MockRead reads[] = { + MockRead(true, reinterpret_cast<const char*>(kGoAway), + arraysize(kGoAway)), + MockRead(true, 0, 0) // EOF + }; + + HttpRequestInfo request; + request.method = "GET"; + request.url = GURL("http://www.google.com/"); + request.load_flags = 0; + scoped_refptr<DelayedSocketData> data( + new DelayedSocketData(1, reads, arraysize(reads), + writes, arraysize(writes))); + TransactionHelperResult out = TransactionHelper(request, data.get(), NULL); + EXPECT_EQ(ERR_CONNECTION_CLOSED, out.rv); +} + } // namespace net diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index 90b040c..64b944e 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -788,6 +788,10 @@ void SpdySession::QueueFrame(spdy::SpdyFrame* frame, } void SpdySession::CloseSessionOnError(net::Error err) { + // Closing all streams can have a side-effect of dropping the last reference + // to |this|. Hold a reference through this function. + scoped_refptr<SpdySession> self(this); + DCHECK_LT(err, OK); LOG(INFO) << "spdy::CloseSessionOnError(" << err << ") for " << host_port_pair().ToString(); |