Author: remy.maucherat(a)jboss.com
Date: 2012-12-21 08:15:27 -0500 (Fri, 21 Dec 2012)
New Revision: 2140
Modified:
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AbstractEndpoint.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AprEndpoint.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/Constants.java
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java
Log:
From my list: add an option for configuration of socket buffer in APR
and NIO2, since Tomcat has it for NIO1.
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AbstractEndpoint.java
===================================================================
---
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AbstractEndpoint.java 2012-12-21
02:23:02 UTC (rev 2139)
+++
branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AbstractEndpoint.java 2012-12-21
13:15:27 UTC (rev 2140)
@@ -152,6 +152,20 @@
*/
protected int keepAliveTimeout = -1;
+ /**
+ * Receive buffer.
+ */
+ protected int soReceiveBuffer = Constants.SO_RCV_BUFFER;
+ public int getSoReceiveBuffer() { return soReceiveBuffer; }
+ public void setSoReceiveBuffer(int soReceiveBuffer) { this.soReceiveBuffer =
soReceiveBuffer; }
+
+ /**
+ * Send buffer.
+ */
+ protected int soSendBuffer = Constants.SO_SND_BUFFER;
+ public int getSoSendBuffer() { return soSendBuffer; }
+ public void setSoSendBuffer(int soSendBuffer) { this.soSendBuffer = soSendBuffer; }
+
/**
* The default is true - the created threads will be in daemon mode. If set
* to false, the control thread will not be daemon - and will keep the
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AprEndpoint.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AprEndpoint.java 2012-12-21
02:23:02 UTC (rev 2139)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/net/AprEndpoint.java 2012-12-21
13:15:27 UTC (rev 2140)
@@ -234,6 +234,22 @@
/**
+ * Receive buffer.
+ */
+ protected int soReceiveBuffer = Constants.SO_RCV_BUFFER;
+ public int getSoReceiveBuffer() { return soReceiveBuffer; }
+ public void setSoReceiveBuffer(int soReceiveBuffer) { this.soReceiveBuffer =
soReceiveBuffer; }
+
+
+ /**
+ * Send buffer.
+ */
+ protected int soSendBuffer = Constants.SO_SND_BUFFER;
+ public int getSoSendBuffer() { return soSendBuffer; }
+ public void setSoSendBuffer(int soSendBuffer) { this.soSendBuffer = soSendBuffer; }
+
+
+ /**
* Keep-Alive timeout.
*/
protected int keepAliveTimeout = -1;
@@ -830,6 +846,10 @@
Socket.optSet(socket, Socket.APR_TCP_NODELAY, (tcpNoDelay ? 1 : 0));
if (soTimeout > 0)
Socket.timeoutSet(socket, soTimeout * 1000);
+ if (soReceiveBuffer > 0)
+ Socket.optSet(socket, Socket.APR_SO_RCVBUF, soReceiveBuffer);
+ if (soSendBuffer > 0)
+ Socket.optSet(socket, Socket.APR_SO_SNDBUF, soSendBuffer);
// 2: SSL handshake
step = 2;
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/net/Constants.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/net/Constants.java 2012-12-21
02:23:02 UTC (rev 2139)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/net/Constants.java 2012-12-21
13:15:27 UTC (rev 2140)
@@ -33,6 +33,12 @@
public static final boolean REUSE_ADDRESS =
Boolean.valueOf(System.getProperty("org.apache.tomcat.util.net.REUSE_ADDRESS",
"true")).booleanValue();
+ public static final int SO_RCV_BUFFER =
+
Integer.valueOf(System.getProperty("org.apache.tomcat.util.net.SO_RCV_BUFFER",
"-1")).intValue();
+
+ public static final int SO_SND_BUFFER =
+
Integer.valueOf(System.getProperty("org.apache.tomcat.util.net.SO_SND_BUFFER",
"-1")).intValue();
+
/**
* The Request attribute key for the cipher suite.
*/
Modified: branches/7.2.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java 2012-12-21
02:23:02 UTC (rev 2139)
+++ branches/7.2.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java 2012-12-21
13:15:27 UTC (rev 2140)
@@ -349,6 +349,12 @@
if (tcpNoDelay) {
channel.setOption(StandardSocketOptions.TCP_NODELAY, tcpNoDelay);
}
+ if (soReceiveBuffer > 0) {
+ channel.setOption(StandardSocketOptions.SO_RCVBUF, soReceiveBuffer);
+ }
+ if (soSendBuffer > 0) {
+ channel.setOption(StandardSocketOptions.SO_SNDBUF, soSendBuffer);
+ }
// Initialize the channel
serverSocketChannelFactory.initChannel(channel);