mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-10 03:56:17 +00:00
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:
parent
bf6371eae6
commit
55c231d227
@ -448,7 +448,10 @@ protected BasicPoolEntry getFreeEntry(RouteSpecificPool rospl, Object state) {
|
|||||||
LOG.debug("Closing expired free connection"
|
LOG.debug("Closing expired free connection"
|
||||||
+ " [" + rospl.getRoute() + "][" + state + "]");
|
+ " [" + rospl.getRoute() + "][" + state + "]");
|
||||||
closeConnection(entry.getConnection());
|
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--;
|
numConnections--;
|
||||||
} else {
|
} else {
|
||||||
issuedConnections.add(entry.getWeakRef());
|
issuedConnections.add(entry.getWeakRef());
|
||||||
|
@ -311,9 +311,9 @@ public void testKeepAliveHeaderRespected() throws Exception {
|
|||||||
HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
|
HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
|
||||||
HttpProtocolParams.setUseExpectContinue(params, false);
|
HttpProtocolParams.setUseExpectContinue(params, false);
|
||||||
HttpConnectionParams.setStaleCheckingEnabled(params, false);
|
HttpConnectionParams.setStaleCheckingEnabled(params, false);
|
||||||
ConnManagerParams.setMaxTotalConnections(params, 5);
|
ConnManagerParams.setMaxTotalConnections(params, 1);
|
||||||
ConnManagerParams.setMaxConnectionsPerRoute(params,
|
ConnManagerParams.setMaxConnectionsPerRoute(params,
|
||||||
new ConnPerRouteBean(5));
|
new ConnPerRouteBean(1));
|
||||||
|
|
||||||
SchemeRegistry supportedSchemes = new SchemeRegistry();
|
SchemeRegistry supportedSchemes = new SchemeRegistry();
|
||||||
SocketFactory sf = PlainSocketFactory.getSocketFactory();
|
SocketFactory sf = PlainSocketFactory.getSocketFactory();
|
||||||
@ -360,7 +360,7 @@ public void testKeepAliveHeaderRespected() throws Exception {
|
|||||||
|
|
||||||
|
|
||||||
mgr.shutdown();
|
mgr.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class WorkerThread extends Thread {
|
private static class WorkerThread extends Thread {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user