Fix socket properties usage so that we can decide if we want to accept the default...
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 11 Nov 2008 20:00:26 +0000 (20:00 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 11 Nov 2008 20:00:26 +0000 (20:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@713144 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/http11/Http11NioProtocol.java
java/org/apache/tomcat/util/net/NioEndpoint.java
java/org/apache/tomcat/util/net/SocketProperties.java

index 3103460..e36a178 100644 (file)
@@ -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();
index 57f61dd..23e1ad8 100644 (file)
@@ -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
index 1a39718..2a3e17c 100644 (file)
@@ -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() {