From: fhanik Date: Wed, 8 Oct 2008 23:28:51 +0000 (+0000) Subject: Expose all socket settings available for the JIO connector, buffer size can make... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b8493d5ec168abb279c2fead30282283f08271f1;p=tomcat7.0 Expose all socket settings available for the JIO connector, buffer size can make large differences, but they are hidden Make settings consistent with those for the NIO connector, so switching between Java connectors is seamless git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@703017 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/coyote/http11/Http11Protocol.java b/java/org/apache/coyote/http11/Http11Protocol.java index cd4cba5d3..b4740d44d 100644 --- a/java/org/apache/coyote/http11/Http11Protocol.java +++ b/java/org/apache/coyote/http11/Http11Protocol.java @@ -123,8 +123,12 @@ public class Http11Protocol /** * Set a property. */ - public void setProperty(String name, String value) { + public boolean setProperty(String name, String value) { setAttribute(name, value); + if (name.startsWith("socket.")) { + return endpoint.setProperty(name, value); + } + return true; } /** diff --git a/java/org/apache/tomcat/util/net/JIoEndpoint.java b/java/org/apache/tomcat/util/net/JIoEndpoint.java index b77e98586..1dfdf38e8 100644 --- a/java/org/apache/tomcat/util/net/JIoEndpoint.java +++ b/java/org/apache/tomcat/util/net/JIoEndpoint.java @@ -26,6 +26,7 @@ import java.util.concurrent.Executor; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; +import org.apache.tomcat.util.IntrospectionUtils; import org.apache.tomcat.util.res.StringManager; /** @@ -127,11 +128,32 @@ public class JIoEndpoint { * Associated server socket. */ protected ServerSocket serverSocket = null; + + /** + * Holds all the socket properties + */ + protected SocketProperties socketProperties = new SocketProperties(); // ------------------------------------------------------------- Properties - + /** + * Generic properties - currently only socket.XXX properties + */ + public boolean setProperty(String name, String value) { + final String socketName = "socket."; + try { + if (name.startsWith(socketName)) { + return IntrospectionUtils.setProperty(socketProperties, name.substring(socketName.length()), value); + } else { + return IntrospectionUtils.setProperty(this,name,value); + } + }catch ( Exception x ) { + log.error("Unable to set attribute \""+name+"\" to \""+value+"\"",x); + return false; + } + } + /** * Acceptor thread count. */ @@ -201,25 +223,30 @@ public class JIoEndpoint { /** * Socket TCP no delay. */ - protected boolean tcpNoDelay = false; - public boolean getTcpNoDelay() { return tcpNoDelay; } - public void setTcpNoDelay(boolean tcpNoDelay) { this.tcpNoDelay = tcpNoDelay; } + public boolean getTcpNoDelay() { return socketProperties.getTcpNoDelay(); } + public void setTcpNoDelay(boolean tcpNoDelay) { socketProperties.setTcpNoDelay(tcpNoDelay); } /** * Socket linger. */ - protected int soLinger = 100; - public int getSoLinger() { return soLinger; } - public void setSoLinger(int soLinger) { this.soLinger = soLinger; } + public int getSoLinger() {return socketProperties.getSoLingerTime();} + public void setSoLinger(int soLinger) { + if (soLinger>=0) { + socketProperties.setSoLingerOn(true); + socketProperties.setSoLingerTime(soLinger); + } else { + socketProperties.setSoLingerOn(false); + socketProperties.setSoLingerTime(-1); + } + } /** * Socket timeout. */ - protected int soTimeout = -1; - public int getSoTimeout() { return soTimeout; } - public void setSoTimeout(int soTimeout) { this.soTimeout = soTimeout; } + public int getSoTimeout() { return socketProperties.getSoTimeout(); } + public void setSoTimeout(int soTimeout) { socketProperties.setSoTimeout(soTimeout); } /** @@ -617,16 +644,7 @@ public class JIoEndpoint { try { // 1: Set socket options: timeout, linger, etc - if (soLinger >= 0) { - socket.setSoLinger(true, soLinger); - } - if (tcpNoDelay) { - socket.setTcpNoDelay(tcpNoDelay); - } - if (soTimeout > 0) { - socket.setSoTimeout(soTimeout); - } - + socketProperties.setProperties(socket); // 2: SSL handshake step = 2; serverSocketFactory.handshake(socket); diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml index b309653d8..2413514b7 100644 --- a/webapps/docs/config/http.xml +++ b/webapps/docs/config/http.xml @@ -383,6 +383,52 @@ + + + +

(int)The socket receive buffer (SO_RCVBUF) size in bytes. Default value is 25188

+
+ +

(int)The socket send buffer (SO_SNDBUF) size in bytes. Default value is 43800

+
+ +

(bool)same as the standard setting tcpNoDelay. Default value is false

+
+ +

(bool)Boolean value for the socket's keep alive setting (SO_KEEPALIVE). Default is false.

+
+ +

(bool)Boolean value for the socket OOBINLINE setting. Default value is true

+
+ +

(bool)Boolean value for the sockets reuse address option (SO_REUSEADDR). Default value is true

+
+ +

(bool)Boolean value for the sockets so linger option (SO_LINGER). Default value is true. + This option is paired with the soLingerTime value.

+
+ +

(bool)Value in seconds for the sockets so linger option (SO_LINGER). Default value is 25 seconds. + This option is paired with the soLinger value.

+
+ +

(int)Value in milliseconds for the sockets read timeout (SO_TIMEOUT). Default value is 5000 milliseconds.

+
+ +

(byte)Value between 0 and 255 for the traffic class on the socket, 0x04 | 0x08 | 0x010

+
+ +

(int)The first value for the performance settings. Default is 1, see Socket Performance Options

+
+ +

(int)The second value for the performance settings. Default is 0, see Socket Performance Options

+
+ +

(int)The third value for the performance settings. Default is 1, see Socket Performance Options

+
+ + +
@@ -458,12 +504,6 @@
When you are using direct buffers, make sure you allocate the appropriate amount of memory for the direct memory space. On Sun's JDK that would be something like -XX:MaxDirectMemorySize=256m

- -

(int)The socket receive buffer (SO_RCVBUF) size in bytes. Default value is 25188

-
- -

(int)The socket send buffer (SO_SNDBUF) size in bytes. Default value is 43800

-

(int)Each connection that is opened up in Tomcat get associated with a read and a write ByteBuffer This attribute controls the size of these buffers. By default this read buffer is sized at 8192 bytes. @@ -511,41 +551,6 @@ The default is 500. Other values are -1. unlimited cache, and 0, no cache.

- -

(bool)same as the standard setting tcpNoDelay. Default value is false

-
- -

(bool)Boolean value for the socket's keep alive setting (SO_KEEPALIVE). Default is false.

-
- -

(bool)Boolean value for the socket OOBINLINE setting. Default value is true

-
- -

(bool)Boolean value for the sockets reuse address option (SO_REUSEADDR). Default value is true

-
- -

(bool)Boolean value for the sockets so linger option (SO_LINGER). Default value is true. - This option is paired with the soLingerTime value.

-
- -

(bool)Value in seconds for the sockets so linger option (SO_LINGER). Default value is 25 seconds. - This option is paired with the soLinger value.

-
- -

(int)Value in milliseconds for the sockets read timeout (SO_TIMEOUT). Default value is 5000 milliseconds.

-
- -

(byte)Value between 0 and 255 for the traffic class on the socket, 0x04 | 0x08 | 0x010

-
- -

(int)The first value for the performance settings. Default is 1, see Socket Performance Options

-
- -

(int)The second value for the performance settings. Default is 0, see Socket Performance Options

-
- -

(int)The third value for the performance settings. Default is 1, see Socket Performance Options

-

(int)The max selectors to be used in the pool, to reduce selector contention. Use this option when the command line org.apache.tomcat.util.net.NioSelectorShared value is set to false. @@ -738,10 +743,10 @@ Classname Http11Protocol Http11NioProtocol Http11AprProtocol Tomcat Version 3.x 4.x 5.x 6.x 6.x 5.5.x 6.x Support Polling NO YES YES - Polling Size N/A Unlimited - Restricted by mem Unlimited - Read HTTP Request Blocking Blocking Blocking - Read HTTP Body Blocking Blocking Blocking - Write HTTP Response Blocking Blocking Blocking + Polling Size N/A Unlimited - Restricted by mem Unlimited - Configurable + Read HTTP Request Blocking Non Blocking Blocking + Read HTTP Body Blocking Sim Blocking Blocking + Write HTTP Response Blocking Sim Blocking Blocking SSL Support Java SSL Java SSL OpenSSL SSL Handshake Blocking Non blocking Blocking Max Connections maxThreads See polling size See polling size