From 2489bcd45e8222b547e504e37359ed9ad4579cff Mon Sep 17 00:00:00 2001 From: remm Date: Wed, 29 Nov 2006 15:28:00 +0000 Subject: [PATCH] - Experiment with using soTimeout as the keepAliveTimeout if it's not specified (this way, the configuration behavior remains the same as before - by default). git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@480598 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/coyote/ajp/Constants.java | 4 +--- java/org/apache/coyote/http11/Constants.java | 1 - java/org/apache/coyote/http11/Http11AprProtocol.java | 4 ++++ java/org/apache/coyote/http11/Http11Processor.java | 2 +- java/org/apache/coyote/http11/Http11Protocol.java | 14 +++----------- java/org/apache/tomcat/util/net/AprEndpoint.java | 5 +++++ 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/java/org/apache/coyote/ajp/Constants.java b/java/org/apache/coyote/ajp/Constants.java index f241742bc..a5d533de9 100644 --- a/java/org/apache/coyote/ajp/Constants.java +++ b/java/org/apache/coyote/ajp/Constants.java @@ -17,9 +17,8 @@ package org.apache.coyote.ajp; -import java.lang.IndexOutOfBoundsException; import java.util.Hashtable; -import java.util.Locale; + import org.apache.tomcat.util.buf.ByteChunk; @@ -42,7 +41,6 @@ public final class Constants { public static final int DEFAULT_CONNECTION_LINGER = -1; public static final int DEFAULT_CONNECTION_TIMEOUT = -1; public static final int DEFAULT_CONNECTION_UPLOAD_TIMEOUT = 300000; - public static final int DEFAULT_KEEPALIVE_TIMEOUT = -1; public static final int DEFAULT_SERVER_SOCKET_TIMEOUT = 0; public static final boolean DEFAULT_TCP_NO_DELAY = true; diff --git a/java/org/apache/coyote/http11/Constants.java b/java/org/apache/coyote/http11/Constants.java index d763a6cd1..ff07a60d1 100644 --- a/java/org/apache/coyote/http11/Constants.java +++ b/java/org/apache/coyote/http11/Constants.java @@ -39,7 +39,6 @@ public final class Constants { public static final int DEFAULT_CONNECTION_LINGER = -1; public static final int DEFAULT_CONNECTION_TIMEOUT = 60000; public static final int DEFAULT_CONNECTION_UPLOAD_TIMEOUT = 300000; - public static final int DEFAULT_KEEPALIVE_TIMEOUT = 60000; public static final int DEFAULT_SERVER_SOCKET_TIMEOUT = 0; public static final boolean DEFAULT_TCP_NO_DELAY = true; diff --git a/java/org/apache/coyote/http11/Http11AprProtocol.java b/java/org/apache/coyote/http11/Http11AprProtocol.java index caf6c378d..1f12d153d 100644 --- a/java/org/apache/coyote/http11/Http11AprProtocol.java +++ b/java/org/apache/coyote/http11/Http11AprProtocol.java @@ -476,6 +476,10 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration ep.setKeepAliveTimeout(timeout); } + public boolean getKeepAlive() { + return ((maxKeepAliveRequests != 0) && (maxKeepAliveRequests != 1)); + } + /** * Set the keep-alive policy for this connection. */ diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index fb27ae537..0ce7ccf06 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -190,7 +190,7 @@ public class Http11Processor implements ActionHook { * The number of seconds Tomcat will wait for a subsequent request * before closing the connection. */ - protected int keepAliveTimeout = 15000; + protected int keepAliveTimeout = -1; /** diff --git a/java/org/apache/coyote/http11/Http11Protocol.java b/java/org/apache/coyote/http11/Http11Protocol.java index 881d332f9..c83e47e28 100644 --- a/java/org/apache/coyote/http11/Http11Protocol.java +++ b/java/org/apache/coyote/http11/Http11Protocol.java @@ -71,7 +71,6 @@ public class Http11Protocol public Http11Protocol() { setSoLinger(Constants.DEFAULT_CONNECTION_LINGER); setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT); - setKeepAliveTimeout(Constants.DEFAULT_KEEPALIVE_TIMEOUT); //setServerSoTimeout(Constants.DEFAULT_SERVER_SOCKET_TIMEOUT); setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY); } @@ -292,16 +291,9 @@ public class Http11Protocol * before closing the connection. The default is the same as for * Apache HTTP Server (15 000 milliseconds). */ - protected int keepAliveTimeout = 15000; - public int getKeepAliveTimeout() - { - return keepAliveTimeout; - } - - public void setKeepAliveTimeout(int timeout) - { - keepAliveTimeout = timeout; - } + protected int keepAliveTimeout = -1; + public int getKeepAliveTimeout() { return keepAliveTimeout; } + public void setKeepAliveTimeout(int timeout) { keepAliveTimeout = timeout; } // HTTP /** diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java index 9ba4dc89d..6d6b000f8 100644 --- a/java/org/apache/tomcat/util/net/AprEndpoint.java +++ b/java/org/apache/tomcat/util/net/AprEndpoint.java @@ -652,6 +652,11 @@ public class AprEndpoint { } } + // Initialize keepalive timeout if it has not been set + if (keepAliveTimeout == -1) { + keepAliveTimeout = soTimeout; + } + // Delay accepting of new connections until data is available // Only Linux kernels 2.4 + have that implemented // on other platforms this call is noop and will return APR_ENOTIMPL. -- 2.11.0