From fe6bac399ff46bb14dfda2fcc01a98c1f50612cf Mon Sep 17 00:00:00 2001 From: fhanik Date: Tue, 11 Nov 2008 20:00:26 +0000 Subject: [PATCH] Fix socket properties usage so that we can decide if we want to accept the default value or if we want to use a preset value git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@713144 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/coyote/http11/Http11NioProtocol.java | 4 -- java/org/apache/tomcat/util/net/NioEndpoint.java | 9 +-- .../apache/tomcat/util/net/SocketProperties.java | 70 ++++++++++------------ 3 files changed, 31 insertions(+), 52 deletions(-) diff --git a/java/org/apache/coyote/http11/Http11NioProtocol.java b/java/org/apache/coyote/http11/Http11NioProtocol.java index 310346016..e36a178e1 100644 --- a/java/org/apache/coyote/http11/Http11NioProtocol.java +++ b/java/org/apache/coyote/http11/Http11NioProtocol.java @@ -132,10 +132,6 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration ep.setName(getName()); ep.setHandler(cHandler); - //todo, determine if we even need these - ep.getSocketProperties().setRxBufSize(Math.max(ep.getSocketProperties().getRxBufSize(),getMaxHttpHeaderSize())); - ep.getSocketProperties().setTxBufSize(Math.max(ep.getSocketProperties().getTxBufSize(),getMaxHttpHeaderSize())); - try { ep.init(); sslImplementation = new JSSEImplementation(); diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 57f61ddd7..23e1ad88d 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -735,14 +735,7 @@ public class NioEndpoint { return; serverSock = ServerSocketChannel.open(); - int performanceConnectionTime = socketProperties.getPerformanceConnectionTime(); - int performanceLatency= socketProperties.getPerformanceLatency(); - int performanceBandwidth = socketProperties.getPerformanceBandwidth(); - if (performanceConnectionTime != -1 && performanceLatency != -1 && - performanceBandwidth != -1) - serverSock.socket().setPerformancePreferences(socketProperties.getPerformanceConnectionTime(), - socketProperties.getPerformanceLatency(), - socketProperties.getPerformanceBandwidth()); + socketProperties.setProperties(serverSock.socket()); InetSocketAddress addr = (address!=null?new InetSocketAddress(address,port):new InetSocketAddress(port)); serverSock.socket().bind(addr,backlog); serverSock.configureBlocking(true); //mimic APR behavior diff --git a/java/org/apache/tomcat/util/net/SocketProperties.java b/java/org/apache/tomcat/util/net/SocketProperties.java index 1a39718a2..2a3e17c3c 100644 --- a/java/org/apache/tomcat/util/net/SocketProperties.java +++ b/java/org/apache/tomcat/util/net/SocketProperties.java @@ -16,6 +16,7 @@ */ package org.apache.tomcat.util.net; +import java.net.ServerSocket; import java.net.Socket; import java.net.SocketException; @@ -205,87 +206,76 @@ public class SocketProperties { socket.setTrafficClass(soTrafficClass.intValue()); } + public void setProperties(ServerSocket socket) throws SocketException{ + if (rxBufSize != null) + socket.setReceiveBufferSize(rxBufSize.intValue()); + if (performanceConnectionTime != null && performanceLatency != null && + performanceBandwidth != null) + socket.setPerformancePreferences( + performanceConnectionTime.intValue(), + performanceLatency.intValue(), + performanceBandwidth.intValue()); + if (soReuseAddress != null) + socket.setReuseAddress(soReuseAddress.booleanValue()); + if (soTimeout != null) + socket.setSoTimeout(soTimeout.intValue()); + } + + public boolean getDirectBuffer() { return directBuffer; } public boolean getOoBInline() { - if(ooBInline != null) - return ooBInline.booleanValue(); - return false; + return ooBInline.booleanValue(); } public int getPerformanceBandwidth() { - if(performanceBandwidth != null) - return performanceBandwidth.intValue(); - return -1; + return performanceBandwidth.intValue(); } public int getPerformanceConnectionTime() { - if(performanceConnectionTime!= null) - return performanceConnectionTime.intValue(); - return -1; - + return performanceConnectionTime.intValue(); } public int getPerformanceLatency() { - if(performanceLatency != null) - return performanceLatency.intValue(); - return -1 ; + return performanceLatency.intValue(); } public int getRxBufSize() { - if(rxBufSize != null) - return rxBufSize.intValue(); - return -1; + return rxBufSize.intValue(); } public boolean getSoKeepAlive() { - if(soKeepAlive != null) - return soKeepAlive.booleanValue(); - return false; + return soKeepAlive.booleanValue(); } public boolean getSoLingerOn() { - if(soLingerOn != null) - return soLingerOn.booleanValue(); - return false; + return soLingerOn.booleanValue(); } public int getSoLingerTime() { - if(soLingerTime != null) - return soLingerTime.intValue(); - return -1; + return soLingerTime.intValue(); } public boolean getSoReuseAddress() { - if(soReuseAddress != null) - return soReuseAddress.booleanValue(); - return false; + return soReuseAddress.booleanValue(); } public int getSoTimeout() { - if(soTimeout != null) - return soTimeout.intValue(); - return -1; + return soTimeout.intValue(); } public int getSoTrafficClass() { - if(soTrafficClass != null) - return soTrafficClass.intValue(); - return -1; + return soTrafficClass.intValue(); } public boolean getTcpNoDelay() { - if(tcpNoDelay != null) - return tcpNoDelay.booleanValue(); - return false; + return tcpNoDelay.booleanValue(); } public int getTxBufSize() { - if(txBufSize != null) - return txBufSize.intValue(); - return -1; + return txBufSize.intValue(); } public int getBufferPool() { -- 2.11.0