fixed keep-alive problem reported by Paul Linder -- expired connections weren't accurately decrementing the total connection count, causing total-connection limits to gradually decay, stalling connections.

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@672973 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sam Berlin 2008-07-01 01:49:10 +00:00
parent bf6371eae6
commit 55c231d227
2 changed files with 7 additions and 4 deletions

View File

@ -448,7 +448,10 @@ protected BasicPoolEntry getFreeEntry(RouteSpecificPool rospl, Object state) {
LOG.debug("Closing expired free connection"
+ " [" + rospl.getRoute() + "][" + state + "]");
closeConnection(entry.getConnection());
rospl.deleteEntry(entry);
// We use dropEntry instead of deleteEntry because the entry
// is no longer "free" (we just allocated it), and deleteEntry
// can only be used to delete free entries.
rospl.dropEntry();
numConnections--;
} else {
issuedConnections.add(entry.getWeakRef());

View File

@ -311,9 +311,9 @@ public void testKeepAliveHeaderRespected() throws Exception {
HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
HttpProtocolParams.setUseExpectContinue(params, false);
HttpConnectionParams.setStaleCheckingEnabled(params, false);
ConnManagerParams.setMaxTotalConnections(params, 5);
ConnManagerParams.setMaxTotalConnections(params, 1);
ConnManagerParams.setMaxConnectionsPerRoute(params,
new ConnPerRouteBean(5));
new ConnPerRouteBean(1));
SchemeRegistry supportedSchemes = new SchemeRegistry();
SocketFactory sf = PlainSocketFactory.getSocketFactory();
@ -360,7 +360,7 @@ public void testKeepAliveHeaderRespected() throws Exception {
mgr.shutdown();
}
}
private static class WorkerThread extends Thread {