Intermittent "connection refused" errors [@ nsHttpHandler::GetConnection_Locked]

Pop oldest idle connection when a new one is created and maxConnections is exceeded.
bug 91429 r=bbaetz sr=darin a=asa
This commit is contained in:
badami%netscape.com 2002-02-22 14:02:40 +00:00
Родитель 66e676c78b
Коммит 2906cee182
1 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -736,6 +736,24 @@ nsHttpHandler::GetConnection_Locked(nsHttpConnectionInfo *ci,
NS_RELEASE(conn);
return rv;
}
// We created a new connection
// If idle + active connections > max connections, then purge the oldest idle one.
if (mIdleConnections.Count() + mActiveConnections.Count() > mMaxConnections) {
LOG(("Created a new connection and popping oldest one [idlecount=%d activecount=%d maxConn=%d]\n",
mIdleConnections.Count(), mActiveConnections.Count(), mMaxConnections));
NS_ASSERTION(mIdleConnections.Count() > 0, "idle connection list is empty");
if (mIdleConnections.Count() > 0) {
nsHttpConnection *conn = (nsHttpConnection *) mIdleConnections[0];
NS_ASSERTION(conn, "mIdleConnections[0] is null but count > 0");
if (conn) {
LOG(("deleting connection [conn=%x host=%s:%d]\n",
conn, conn->ConnectionInfo()->Host(), conn->ConnectionInfo()->Port()));
mIdleConnections.RemoveElementAt(0);
NS_RELEASE(conn);
}
}
}
}
else {
// Update the connectionInfo (bug 94038)