Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1696)

Unified Diff: net/spdy/spdy_session.cc

Issue 8340012: Close idle connections / SPDY sessions when needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: OVERRIDE Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« net/socket/ssl_client_socket_pool.cc ('K') | « net/spdy/spdy_session.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_session.cc
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index bc8a100379d309e2776202fd42640c9e01552da0..cf1ccd76e76b6ab6549f098fe5eabff31b9b2644 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -331,6 +331,7 @@ net::Error SpdySession::InitializeWithSocket(
state_ = CONNECTED;
connection_.reset(connection);
+ connection_->AddLayeredPool(this);
is_secure_ = is_secure;
certificate_error_code_ = certificate_error_code;
@@ -967,6 +968,15 @@ int SpdySession::GetLocalAddress(IPEndPoint* address) const {
return connection_->socket()->GetLocalAddress(address);
}
+bool SpdySession::CloseOneIdleConnection() {
+ if (num_active_streams() == 0) {
+ // Should delete this.
+ RemoveFromPool();
mmenke 2011/10/27 18:52:37 Is this safe? It looks to me like there may be no
willchan no longer on Chromium 2011/11/08 22:26:13 I'm not sure I understand the worry. When we call
mmenke 2011/11/08 22:41:04 We don't dereference |this|, but RemoveFromPool do
willchan no longer on Chromium 2011/11/15 18:44:06 Again, great catch. I've fixed this.
+ return true;
+ }
+ return false;
+}
+
void SpdySession::ActivateStream(SpdyStream* stream) {
const spdy::SpdyStreamId id = stream->stream_id();
DCHECK(!IsStreamActive(id));
@@ -1001,6 +1011,10 @@ void SpdySession::DeleteStream(spdy::SpdyStreamId id, int status) {
if (stream)
stream->OnClose(status);
ProcessPendingCreateStreams();
+ if (num_active_streams() == 0 && connection_->IsPoolStalled()) {
+ // Should delete this.
+ RemoveFromPool();
+ }
}
void SpdySession::RemoveFromPool() {
« net/socket/ssl_client_socket_pool.cc ('K') | « net/spdy/spdy_session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698