From 37a09dd732b4ebb898c8abf95a11e1675c0a6abd Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Wed, 24 Apr 2013 23:45:40 -0700 Subject: [PATCH] Back out 96a806212cac (bug 865314) for apparently causing fairly frequent failures in test_spdy.js --- .../protocol/http/ConnectionDiagnostics.cpp | 4 +-- netwerk/protocol/http/nsHttpConnectionMgr.cpp | 33 +++++-------------- netwerk/protocol/http/nsHttpConnectionMgr.h | 6 ++++ 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/netwerk/protocol/http/ConnectionDiagnostics.cpp b/netwerk/protocol/http/ConnectionDiagnostics.cpp index ae0ef20c06d5..ca3f839b4485 100644 --- a/netwerk/protocol/http/ConnectionDiagnostics.cpp +++ b/netwerk/protocol/http/ConnectionDiagnostics.cpp @@ -68,8 +68,8 @@ nsHttpConnectionMgr::PrintDiagnosticsCB(const nsACString &key, ent->mHalfOpens.Length()); self->mLogData.AppendPrintf(" Coalescing Key = %s\n", ent->mCoalescingKey.get()); - self->mLogData.AppendPrintf(" Spdy using = %d, preferred = %d\n", - ent->mUsingSpdy, ent->mSpdyPreferred); + self->mLogData.AppendPrintf(" Spdy using = %d, tested = %d, preferred = %d\n", + ent->mUsingSpdy, ent->mTestedSpdy, ent->mSpdyPreferred); self->mLogData.AppendPrintf(" pipelinestate = %d penalty = %d\n", ent->mPipelineState, ent->mPipeliningPenalty); for (i = 0; i < nsAHttpTransaction::CLASS_MAX; ++i) { diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index 32d67f157f78..08fccd0f5863 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -521,6 +521,8 @@ nsHttpConnectionMgr::ReportSpdyConnection(nsHttpConnection *conn, if (!ent) return; + ent->mTestedSpdy = true; + if (!usingSpdy) return; @@ -562,28 +564,7 @@ nsHttpConnectionMgr::ReportSpdyConnection(nsHttpConnection *conn, // normally, but then it will go away and future connections will be // coalesced through the preferred entry. - LOG(("ReportSpdyConnection shutting down connection because " - "of desharding\n")); - conn->DontReuse(); - } - else if (ent->mActiveConns.Length() > 1) { - // this is a new connection to an established preferred spdy host. - // if there is more than 1 live and established spdy connection (e.g. - // some could still be handshaking, shutting down, etc..) then close - // this one down after any transactions that are on it are complete. - // This probably happened due to the parallel connection algorithm - // that is used only before the host is known to speak spdy. - for (uint32_t index = 0; index < ent->mActiveConns.Length(); ++index) { - nsHttpConnection *otherConn = ent->mActiveConns[index]; - if (otherConn == conn) - continue; - if (conn->CanDirectlyActivate()) { - LOG(("ReportSpdyConnection shutting down connection because more " - "than 1 active spdy connection is live to this host\n")); - conn->DontReuse(); - break; - } - } + conn->DontReuse(); } PostEvent(&nsHttpConnectionMgr::OnMsgProcessAllSpdyPendingQ); @@ -970,8 +951,9 @@ nsHttpConnectionMgr::PruneDeadConnectionsCB(const nsACString &key, ent->mActiveConns.Length() == 0 && ent->mHalfOpens.Length() == 0 && ent->mPendingQ.Length() == 0 && - !ent->mUsingSpdy && - self->mCT.Count() > 300) { + ((!ent->mTestedSpdy && !ent->mUsingSpdy) || + !gHttpHandler->IsSpdyEnabled() || + self->mCT.Count() > 300)) { LOG((" removing empty connection entry\n")); return PL_DHASH_REMOVE; } @@ -1307,7 +1289,7 @@ nsHttpConnectionMgr::RestrictConnections(nsConnectionEntry *ent) bool doRestrict = ent->mConnInfo->UsingSSL() && gHttpHandler->IsSpdyEnabled() && - ent->mUsingSpdy && + (!ent->mTestedSpdy || ent->mUsingSpdy) && (ent->mHalfOpens.Length() || ent->mActiveConns.Length()); // If there are no restrictions, we are done @@ -3122,6 +3104,7 @@ nsConnectionEntry::nsConnectionEntry(nsHttpConnectionInfo *ci) , mPipeliningPenalty(0) , mSpdyCWND(0) , mUsingSpdy(false) + , mTestedSpdy(false) , mSpdyPreferred(false) , mPreferIPv4(false) , mPreferIPv6(false) diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.h b/netwerk/protocol/http/nsHttpConnectionMgr.h index 4fa923c5ec36..97614d600f2a 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.h +++ b/netwerk/protocol/http/nsHttpConnectionMgr.h @@ -358,6 +358,12 @@ private: // connection is currently using spdy. bool mUsingSpdy; + // mTestedSpdy is set after NPN negotiation has occurred and we know + // with confidence whether a host speaks spdy or not (which is reflected + // in mUsingSpdy). Before mTestedSpdy is set, handshake parallelism is + // minimized so that we can multiplex on a single spdy connection. + bool mTestedSpdy; + bool mSpdyPreferred; // Flags to remember our happy-eyeballs decision.