/**
+ * Processors (currently only HTTP BIO) may elect to disable HTTP keep-alive
+ * in some circumstances. This method allows the processor implementation to
+ * determine if keep-alive should be disabled or not.
+ */
+ protected abstract boolean disableKeepAlive();
+
+
+ /**
* After reading the request headers, we have to setup the request filters.
*/
protected void prepareRequest() {
long soTimeout = endpoint.getSoTimeout();
+ if (disableKeepAlive()) {
+ socketWrapper.setKeepAliveLeft(0);
+ }
+
boolean keptAlive = false;
boolean openSocket = false;
boolean sendfileInProgress = false;
@Override
+ protected boolean disableKeepAlive() {
+ return false;
+ }
+
+
+ @Override
protected void resetTimeouts() {
// NOOP for APR
}
long soTimeout = endpoint.getSoTimeout();
+ if (disableKeepAlive()) {
+ socketWrapper.setKeepAliveLeft(0);
+ }
+
boolean keptAlive = false;
boolean openSocket = false;
boolean readComplete = true;
@Override
+ protected boolean disableKeepAlive() {
+ return false;
+ }
+
+
+ @Override
public void recycleInternal() {
socket = null;
cometClose = false;
int soTimeout = endpoint.getSoTimeout();
- int threadRatio = -1;
- // These may return zero or negative values
- // Only calculate a thread ratio when both are >0 to ensure we get a
- // sensible result
- if (endpoint.getCurrentThreadsBusy() >0 &&
- endpoint.getMaxThreads() >0) {
- threadRatio = (endpoint.getCurrentThreadsBusy() * 100)
- / endpoint.getMaxThreads();
- }
- // Disable keep-alive if we are running low on threads
- if (threadRatio > getDisableKeepAlivePercentage()) {
+ if (disableKeepAlive()) {
socketWrapper.setKeepAliveLeft(0);
}
@Override
+ protected boolean disableKeepAlive() {
+ int threadRatio = -1;
+ // These may return zero or negative values
+ // Only calculate a thread ratio when both are >0 to ensure we get a
+ // sensible result
+ if (endpoint.getCurrentThreadsBusy() >0 &&
+ endpoint.getMaxThreads() >0) {
+ threadRatio = (endpoint.getCurrentThreadsBusy() * 100)
+ / endpoint.getMaxThreads();
+ }
+ // Disable keep-alive if we are running low on threads
+ if (threadRatio > getDisableKeepAlivePercentage()) {
+ return true;
+ }
+
+ return false;
+ }
+
+
+ @Override
protected void resetTimeouts() {
// NOOP for APR
}