Author: markt
Date: Wed Jan 16 22:22:22 2013
New Revision: 1434447
URL: http://svn.apache.org/viewvc?rev=1434447&view=rev
Log:
Ensure maxKeepAliveRequests is honoured by the APR/native connector.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1434447&r1=1434446&r2=1434447&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Wed Jan 16
22:22:22 2013
@@ -22,6 +22,8 @@ import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
@@ -97,6 +99,9 @@ public class AprEndpoint extends Abstrac
protected ConcurrentLinkedQueue<SocketWrapper<Long>> waitingRequests =
new ConcurrentLinkedQueue<>();
+ private Map<Long,SocketWrapper<Long>> connections =
+ new ConcurrentHashMap<>();
+
// ------------------------------------------------------------ Constructor
public AprEndpoint() {
@@ -675,6 +680,7 @@ public class AprEndpoint extends Abstrac
// Ignore
}
poller = null;
+ connections.clear();
try {
cometPoller.destroy();
} catch (Exception e) {
@@ -805,6 +811,8 @@ public class AprEndpoint extends Abstrac
if (running) {
SocketWrapper<Long> wrapper =
new SocketWrapper<>(Long.valueOf(socket));
+ wrapper.setKeepAliveLeft(getMaxKeepAliveRequests());
+ connections.put(Long.valueOf(socket), wrapper);
getExecutor().execute(new SocketWithOptionsProcessor(wrapper));
}
} catch (RejectedExecutionException x) {
@@ -833,7 +841,7 @@ public class AprEndpoint extends Abstrac
Long.valueOf(socket), null));
} else {
SocketWrapper<Long> wrapper =
- new SocketWrapper<>(Long.valueOf(socket));
+ connections.get(Long.valueOf(socket));
executor.execute(new SocketProcessor(wrapper, status));
}
} catch (RejectedExecutionException x) {
@@ -907,6 +915,7 @@ public class AprEndpoint extends Abstrac
// countDownConnection(). Once the connector is stopped, the latch is
// removed so it does not matter that destroySocket() does not call
// countDownConnection() in that case
+ connections.remove(Long.valueOf(socket));
destroySocket(socket, running);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]