Index: net/spdy/spdy_session.cc |
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc |
index 412294af7a1b02b258b0eb73a7fa6aaa88b298dd..08844b9f567f74e8a572437224b0508a48d4e444 100644 |
--- a/net/spdy/spdy_session.cc |
+++ b/net/spdy/spdy_session.cc |
@@ -421,6 +421,7 @@ net::Error SpdySession::InitializeWithSocket( |
state_ = CONNECTED; |
connection_.reset(connection); |
+ connection_->AddLayeredPool(this); |
is_secure_ = is_secure; |
certificate_error_code_ = certificate_error_code; |
@@ -1147,6 +1148,8 @@ void SpdySession::CloseSessionOnError(net::Error err, |
if (state_ != CLOSED) { |
state_ = CLOSED; |
error_ = err; |
+ if (connection_ != NULL && connection_->is_initialized()) |
+ connection_->RemoveLayeredPool(this); |
if (remove_from_pool) |
RemoveFromPool(); |
CloseAllStreams(err); |
@@ -1218,6 +1221,18 @@ int SpdySession::GetLocalAddress(IPEndPoint* address) const { |
return connection_->socket()->GetLocalAddress(address); |
} |
+bool SpdySession::CloseOneIdleConnection() { |
+ if (spdy_session_pool_ && num_active_streams() == 0) { |
+ bool ret = HasOneRef(); |
+ // Will remove a reference to this. |
+ RemoveFromPool(); |
+ // Since the underlying socket is only returned when |this| is destroyed |
+ // we should only return true if RemoveFromPool() removed the last ref. |
+ return ret; |
+ } |
+ return false; |
+} |
+ |
void SpdySession::ActivateStream(SpdyStream* stream) { |
const SpdyStreamId id = stream->stream_id(); |
DCHECK(!IsStreamActive(id)); |