bug 1104993 - fix connection manager half open accounting r=hurley

This commit is contained in:
Patrick McManus 2014-11-24 22:42:10 -05:00
parent cf947bfe33
commit 2a387bd714

View File

@ -2181,6 +2181,9 @@ nsHttpConnectionMgr::CreateTransport(nsConnectionEntry *ent,
}
}
// The socket stream holds the reference to the half open
// socket - so if the stream fails to init the half open
// will go away.
nsresult rv = sock->SetupPrimaryStreams();
NS_ENSURE_SUCCESS(rv, rv);
@ -2404,8 +2407,9 @@ nsHttpConnectionMgr::OnMsgCancelTransaction(int32_t reason, void *param)
++index) {
nsHalfOpenSocket *half = ent->mHalfOpens[index];
if (trans == half->Transaction()) {
ent->RemoveHalfOpen(half);
half->Abandon();
// there is only one, and now mHalfOpens[] has been changed.
break;
}
}
}
@ -3894,21 +3898,25 @@ void
nsHttpConnectionMgr::
nsConnectionEntry::RemoveHalfOpen(nsHalfOpenSocket *halfOpen)
{
if (halfOpen->IsSpeculative()) {
Telemetry::AutoCounter<Telemetry::HTTPCONNMGR_UNUSED_SPECULATIVE_CONN> unusedSpeculativeConn;
++unusedSpeculativeConn;
if (halfOpen->IsFromPredictor()) {
Telemetry::AutoCounter<Telemetry::PREDICTOR_TOTAL_PRECONNECTS_UNUSED> totalPreconnectsUnused;
++totalPreconnectsUnused;
}
}
// A failure to create the transport object at all
// will result in it not being present in the halfopen table
// so ignore failures of RemoveElement()
mHalfOpens.RemoveElement(halfOpen);
gHttpHandler->ConnMgr()->mNumHalfOpenConns--;
// will result in it not being present in the halfopen table. That's expected.
if (mHalfOpens.RemoveElement(halfOpen)) {
if (halfOpen->IsSpeculative()) {
Telemetry::AutoCounter<Telemetry::HTTPCONNMGR_UNUSED_SPECULATIVE_CONN> unusedSpeculativeConn;
++unusedSpeculativeConn;
if (halfOpen->IsFromPredictor()) {
Telemetry::AutoCounter<Telemetry::PREDICTOR_TOTAL_PRECONNECTS_UNUSED> totalPreconnectsUnused;
++totalPreconnectsUnused;
}
}
MOZ_ASSERT(gHttpHandler->ConnMgr()->mNumHalfOpenConns);
if (gHttpHandler->ConnMgr()->mNumHalfOpenConns) { // just in case
gHttpHandler->ConnMgr()->mNumHalfOpenConns--;
}
}
if (!UnconnectedHalfOpens())
// perhaps this reverted RestrictConnections()