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

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: Fix clang. Created 9 years, 1 month 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
« no previous file with comments | « 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 cdd71dcaf54ac7c1ac3f3b59440cd680d82d2d75..0543c89f79e73d213fb204ec040fe1fef8001544 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -332,6 +332,7 @@ net::Error SpdySession::InitializeWithSocket(
state_ = CONNECTED;
connection_.reset(connection);
+ connection_->AddLayeredPool(this);
is_secure_ = is_secure;
certificate_error_code_ = certificate_error_code;
@@ -980,6 +981,15 @@ int SpdySession::GetLocalAddress(IPEndPoint* address) const {
return connection_->socket()->GetLocalAddress(address);
}
+bool SpdySession::CloseOneIdleConnection() {
+ if (num_active_streams() == 0) {
+ // Should delete this.
+ RemoveFromPool();
+ return true;
+ }
+ return false;
+}
+
void SpdySession::ActivateStream(SpdyStream* stream) {
const spdy::SpdyStreamId id = stream->stream_id();
DCHECK(!IsStreamActive(id));
@@ -1014,12 +1024,18 @@ void SpdySession::DeleteStream(spdy::SpdyStreamId id, int status) {
if (stream)
stream->OnClose(status);
ProcessPendingCreateStreams();
+ if (num_active_streams() == 0 && connection_->is_initialized() &&
+ connection_->IsPoolStalled()) {
+ // Should delete this.
+ RemoveFromPool();
+ }
}
void SpdySession::RemoveFromPool() {
if (spdy_session_pool_) {
- spdy_session_pool_->Remove(make_scoped_refptr(this));
+ SpdySessionPool* pool = spdy_session_pool_;
spdy_session_pool_ = NULL;
+ pool->Remove(make_scoped_refptr(this));
}
}
« no previous file with comments | « net/spdy/spdy_session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698