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

Unified Diff: net/spdy/spdy_session.cc

Issue 200723004: Fix SPDY error-handling if the connection gets closed just after use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_pool.h » ('j') | 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 c20d89e4a05e40c1cf34bcade93a8ff8840ff02e..5f0e285afc135ad7577ced68f6d2317b75c5d2e1 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -532,7 +532,7 @@ SpdySession::~SpdySession() {
net_log_.EndEvent(NetLog::TYPE_SPDY_SESSION);
}
-Error SpdySession::InitializeWithSocket(
+void SpdySession::InitializeWithSocket(
scoped_ptr<ClientSocketHandle> connection,
SpdySessionPool* pool,
bool is_secure,
@@ -593,19 +593,17 @@ Error SpdySession::InitializeWithSocket(
NetLog::TYPE_SPDY_SESSION_INITIALIZED,
connection_->socket()->NetLog().source().ToEventParametersCallback());
- int error = DoReadLoop(READ_STATE_DO_READ, OK);
- if (error == ERR_IO_PENDING)
- error = OK;
- if (error == OK) {
- DCHECK_NE(availability_state_, STATE_CLOSED);
- connection_->AddHigherLayeredPool(this);
- if (enable_sending_initial_data_)
- SendInitialData();
- pool_ = pool;
- } else {
- DcheckClosed();
- }
- return static_cast<Error>(error);
+ DCHECK_NE(availability_state_, STATE_CLOSED);
+ connection_->AddHigherLayeredPool(this);
+ if (enable_sending_initial_data_)
+ SendInitialData();
+ pool_ = pool;
+
+ // Bootstrap the read loop.
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&SpdySession::PumpReadLoop,
+ weak_factory_.GetWeakPtr(), READ_STATE_DO_READ, OK));
}
bool SpdySession::VerifyDomainAuthentication(const std::string& domain) {
@@ -1554,9 +1552,8 @@ SpdySession::CloseSessionResult SpdySession::DoCloseSession(
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySession.BytesRead.OtherErrors",
total_bytes_received_, 1, 100000000, 50);
- // |pool_| will be NULL when |InitializeWithSocket()| is in the
- // call stack.
- if (pool_ && availability_state_ != STATE_GOING_AWAY)
+ DCHECK(pool_);
+ if (availability_state_ != STATE_GOING_AWAY)
pool_->MakeSessionUnavailable(GetWeakPtr());
availability_state_ = STATE_CLOSED;
@@ -1628,10 +1625,8 @@ void SpdySession::CloseSessionOnError(Error err,
void SpdySession::MakeUnavailable() {
if (availability_state_ < STATE_GOING_AWAY) {
availability_state_ = STATE_GOING_AWAY;
- // |pool_| will be NULL when |InitializeWithSocket()| is in the
- // call stack.
- if (pool_)
- pool_->MakeSessionUnavailable(GetWeakPtr());
+ DCHECK(pool_);
+ pool_->MakeSessionUnavailable(GetWeakPtr());
}
}
@@ -1686,7 +1681,8 @@ base::Value* SpdySession::GetInfoAsValue() const {
}
bool SpdySession::IsReused() const {
- return buffered_spdy_framer_->frames_received() > 0;
+ return buffered_spdy_framer_->frames_received() > 0 ||
+ connection_->reuse_type() == ClientSocketHandle::UNUSED_IDLE;
}
bool SpdySession::GetLoadTimingInfo(SpdyStreamId stream_id,
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698