bug 767742 - close spdy sessions under total connection pressure r=honzab

--HG--
extra : rebase_source : 5fd4d2b73cf5cecfa7862d0e5bfb1354cae4797a
This commit is contained in:
Patrick McManus 2013-03-19 21:27:25 -04:00
parent 492e3d3ea7
commit 984c265b43
2 changed files with 30 additions and 1 deletions

View File

@ -807,7 +807,7 @@ nsHttpConnectionMgr::ProcessAllTransactionsCB(const nsACString &key,
return PL_DHASH_NEXT;
}
// If the global number of idle connections is preventing the opening of
// If the global number of connections is preventing the opening of
// new connections to a host without idle connections, then
// close them regardless of their TTL
PLDHashOperator
@ -832,6 +832,30 @@ nsHttpConnectionMgr::PurgeExcessIdleConnectionsCB(const nsACString &key,
return PL_DHASH_STOP;
}
// If the global number of connections is preventing the opening of
// new connections to a host without idle connections, then
// close any spdy asap
PLDHashOperator
nsHttpConnectionMgr::PurgeExcessSpdyConnectionsCB(const nsACString &key,
nsAutoPtr<nsConnectionEntry> &ent,
void *closure)
{
if (!ent->mUsingSpdy)
return PL_DHASH_NEXT;
nsHttpConnectionMgr *self = static_cast<nsHttpConnectionMgr *>(closure);
for (uint32_t index = 0; index < ent->mActiveConns.Length(); ++index) {
nsHttpConnection *conn = ent->mActiveConns[index];
if (conn->UsingSpdy() && conn->CanReuse()) {
conn->DontReuse();
// stop on <= (particularly =) beacuse this dontreuse causes async close
if (self->mNumIdleConns + self->mNumActiveConns + 1 <= self->mMaxConns)
return PL_DHASH_STOP;
}
}
return PL_DHASH_NEXT;
}
PLDHashOperator
nsHttpConnectionMgr::PruneDeadConnectionsCB(const nsACString &key,
nsAutoPtr<nsConnectionEntry> &ent,
@ -1319,6 +1343,10 @@ nsHttpConnectionMgr::MakeNewConnection(nsConnectionEntry *ent,
if ((mNumIdleConns + mNumActiveConns + 1 >= mMaxConns) && mNumIdleConns)
mCT.Enumerate(PurgeExcessIdleConnectionsCB, this);
if ((mNumIdleConns + mNumActiveConns + 1 >= mMaxConns) &&
mNumActiveConns && gHttpHandler->IsSpdyEnabled())
mCT.Enumerate(PurgeExcessSpdyConnectionsCB, this);
if (AtActiveConnectionLimit(ent, trans->Caps()))
return NS_ERROR_NOT_AVAILABLE;

View File

@ -490,6 +490,7 @@ private:
static PLDHashOperator PruneDeadConnectionsCB(const nsACString &, nsAutoPtr<nsConnectionEntry> &, void *);
static PLDHashOperator ShutdownPassCB(const nsACString &, nsAutoPtr<nsConnectionEntry> &, void *);
static PLDHashOperator PurgeExcessIdleConnectionsCB(const nsACString &, nsAutoPtr<nsConnectionEntry> &, void *);
static PLDHashOperator PurgeExcessSpdyConnectionsCB(const nsACString &, nsAutoPtr<nsConnectionEntry> &, void *);
static PLDHashOperator ClosePersistentConnectionsCB(const nsACString &, nsAutoPtr<nsConnectionEntry> &, void *);
bool ProcessPendingQForEntry(nsConnectionEntry *, bool considerAll);
bool IsUnderPressure(nsConnectionEntry *ent,