From 9061659646542003c959da3720bfcb2bd99a1d68 Mon Sep 17 00:00:00 2001 From: remm Date: Fri, 29 Sep 2006 09:42:56 +0000 Subject: [PATCH] - The addition of keepAliveTimeout is useless for the regular connector, as it already has two different timeouts as an option. - Make it default to soTimeout in the other cases. - Sendfile should not use keepAliveTimeout, but soTimeout. git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@451202 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/catalina/connector/Constants.java | 1 - java/org/apache/coyote/ajp/AjpAprProtocol.java | 1 + java/org/apache/coyote/ajp/Constants.java | 1 - java/org/apache/coyote/http11/Constants.java | 1 - .../apache/coyote/http11/Http11AprProcessor.java | 21 --------------- .../apache/coyote/http11/Http11AprProtocol.java | 1 + java/org/apache/coyote/http11/Http11Processor.java | 31 ++-------------------- java/org/apache/coyote/http11/Http11Protocol.java | 13 --------- java/org/apache/tomcat/util/net/AprEndpoint.java | 8 +++--- 9 files changed, 8 insertions(+), 70 deletions(-) diff --git a/java/org/apache/catalina/connector/Constants.java b/java/org/apache/catalina/connector/Constants.java index 24ddffef9..7f49bb9d0 100644 --- a/java/org/apache/catalina/connector/Constants.java +++ b/java/org/apache/catalina/connector/Constants.java @@ -34,7 +34,6 @@ public final class Constants { public static final int DEFAULT_CONNECTION_TIMEOUT = 60000; public static final int DEFAULT_CONNECTION_UPLOAD_TIMEOUT = 300000; public static final int DEFAULT_SERVER_SOCKET_TIMEOUT = 0; - public static final int DEFAULT_KEEPALIVE_TIMEOUT = 15000; public static final int PROCESSOR_IDLE = 0; public static final int PROCESSOR_ACTIVE = 1; diff --git a/java/org/apache/coyote/ajp/AjpAprProtocol.java b/java/org/apache/coyote/ajp/AjpAprProtocol.java index 73206cd0a..6a10a1d5b 100644 --- a/java/org/apache/coyote/ajp/AjpAprProtocol.java +++ b/java/org/apache/coyote/ajp/AjpAprProtocol.java @@ -68,6 +68,7 @@ public class AjpAprProtocol cHandler = new AjpConnectionHandler(this); setSoLinger(Constants.DEFAULT_CONNECTION_LINGER); setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT); + setKeepAliveTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT); //setServerSoTimeout(Constants.DEFAULT_SERVER_SOCKET_TIMEOUT); setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY); } diff --git a/java/org/apache/coyote/ajp/Constants.java b/java/org/apache/coyote/ajp/Constants.java index 368d563d6..077ee372a 100644 --- a/java/org/apache/coyote/ajp/Constants.java +++ b/java/org/apache/coyote/ajp/Constants.java @@ -38,7 +38,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 = 15000; 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 5f3a2fb6b..46dde8332 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_TIMEOUT = 60000; public static final int DEFAULT_CONNECTION_UPLOAD_TIMEOUT = 300000; public static final int DEFAULT_SERVER_SOCKET_TIMEOUT = 0; - public static final int DEFAULT_KEEPALIVE_TIMEOUT = 15000; public static final boolean DEFAULT_TCP_NO_DELAY = true; diff --git a/java/org/apache/coyote/http11/Http11AprProcessor.java b/java/org/apache/coyote/http11/Http11AprProcessor.java index 9744899ff..e0c858874 100644 --- a/java/org/apache/coyote/http11/Http11AprProcessor.java +++ b/java/org/apache/coyote/http11/Http11AprProcessor.java @@ -209,12 +209,6 @@ public class Http11AprProcessor implements ActionHook { protected int maxKeepAliveRequests = -1; /** - * The number of seconds Tomcat will wait for a subsequent request - * before closing the connection. - */ - protected int keepAliveTimeout = 15000; - - /** * SSL enabled ? */ protected boolean ssl = false; @@ -649,21 +643,6 @@ public class Http11AprProcessor implements ActionHook { } /** - * Set the Keep-Alive timeout. - */ - public void setKeepAliveTimeout(int timeout) { - keepAliveTimeout = timeout; - } - - - /** - * Return the number Keep-Alive timeout. - */ - public int getKeepAliveTimeout() { - return keepAliveTimeout; - } - - /** * Set the maximum size of a POST which will be buffered in SSL mode. */ public void setMaxSavePostSize(int msps) { diff --git a/java/org/apache/coyote/http11/Http11AprProtocol.java b/java/org/apache/coyote/http11/Http11AprProtocol.java index f58275aae..c8706c50a 100644 --- a/java/org/apache/coyote/http11/Http11AprProtocol.java +++ b/java/org/apache/coyote/http11/Http11AprProtocol.java @@ -54,6 +54,7 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration cHandler = new Http11ConnectionHandler( this ); setSoLinger(Constants.DEFAULT_CONNECTION_LINGER); setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT); + setKeepAliveTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT); //setServerSoTimeout(Constants.DEFAULT_SERVER_SOCKET_TIMEOUT); setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY); } diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index b6f3a75e6..a5fc68a36 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -185,12 +185,6 @@ public class Http11Processor implements ActionHook { */ protected int maxKeepAliveRequests = -1; - /** - * The number of seconds Tomcat will wait for a subsequent request - * before closing the connection. - */ - protected int keepAliveTimeout = 15000; - /** * SSL information. @@ -627,22 +621,6 @@ public class Http11Processor implements ActionHook { } /** - * Set the Keep-Alive timeout. - */ - public void setKeepAliveTimeout(int timeout) { - keepAliveTimeout = timeout; - } - - - /** - * Return the number Keep-Alive timeout. - */ - public int getKeepAliveTimeout() { - return keepAliveTimeout; - } - - - /** * Set the maximum size of a POST which will be buffered in SSL mode. */ public void setMaxSavePostSize(int msps) { @@ -799,13 +777,8 @@ public class Http11Processor implements ActionHook { // Parsing the request header try { - if (!disableUploadTimeout && keptAlive) { - if (keepAliveTimeout > 0) { - socket.setSoTimeout(keepAliveTimeout); - } - else if (soTimeout > 0) { - socket.setSoTimeout(soTimeout); - } + if( !disableUploadTimeout && keptAlive && soTimeout > 0 ) { + socket.setSoTimeout(soTimeout); } inputBuffer.parseRequestLine(); request.setStartTime(System.currentTimeMillis()); diff --git a/java/org/apache/coyote/http11/Http11Protocol.java b/java/org/apache/coyote/http11/Http11Protocol.java index 8a37d6aef..9483c816d 100644 --- a/java/org/apache/coyote/http11/Http11Protocol.java +++ b/java/org/apache/coyote/http11/Http11Protocol.java @@ -70,7 +70,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); } @@ -284,17 +283,6 @@ public class Http11Protocol // HTTP /** - * The number of seconds Tomcat will wait for a subsequent request - * 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; } - - - // HTTP - /** * This timeout represents the socket timeout which will be used while * the adapter execution is in progress, unless disableUploadTimeout * is set to true. The default is the same as for Apache HTTP Server @@ -591,7 +579,6 @@ public class Http11Protocol new Http11Processor(protocol.maxHttpHeaderSize, protocol.endpoint); processor.setAdapter(protocol.adapter); processor.setMaxKeepAliveRequests(protocol.maxKeepAliveRequests); - processor.setKeepAliveTimeout(protocol.keepAliveTimeout); processor.setTimeout(protocol.timeout); processor.setDisableUploadTimeout(protocol.disableUploadTimeout); processor.setCompression(protocol.compression); diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java index 2ec532ff9..a9f7f5ca9 100644 --- a/java/org/apache/tomcat/util/net/AprEndpoint.java +++ b/java/org/apache/tomcat/util/net/AprEndpoint.java @@ -258,7 +258,7 @@ public class AprEndpoint { /** * Keep-Alive timeout. */ - protected int keepAliveTimeout = 15000; + protected int keepAliveTimeout = -1; public int getKeepAliveTimeout() { return keepAliveTimeout; } public void setKeepAliveTimeout(int timeout) { keepAliveTimeout = timeout; } @@ -1573,14 +1573,14 @@ public class AprEndpoint { protected void init() { pool = Pool.create(serverSockPool); int size = sendfileSize / sendfileThreadCount; - sendfilePollset = allocatePoller(size, pool, keepAliveTimeout); + sendfilePollset = allocatePoller(size, pool, soTimeout); if (sendfilePollset == 0 && size > 1024) { size = 1024; - sendfilePollset = allocatePoller(size, pool, keepAliveTimeout); + sendfilePollset = allocatePoller(size, pool, soTimeout); } if (sendfilePollset == 0) { size = 62; - sendfilePollset = allocatePoller(size, pool, keepAliveTimeout); + sendfilePollset = allocatePoller(size, pool, soTimeout); } desc = new long[size * 2]; sendfileData = new HashMap(size); -- 2.11.0