Expose deferAccept for APR HTTP connector.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 27 Oct 2008 22:04:51 +0000 (22:04 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 27 Oct 2008 22:04:51 +0000 (22:04 +0000)
I did consider adding this to the AJP connector as well but since this is to work around a buggy client and we control the client in the AJP case, I couldn't see a need for it.
Patch provided by Michael Leinartas.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@708344 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/http11/Http11AprProtocol.java
java/org/apache/tomcat/util/net/AprEndpoint.java
webapps/docs/config/ajp.xml

index c19c38c..c7c6c7d 100644 (file)
@@ -250,7 +250,10 @@ public class Http11AprProtocol implements ProtocolHandler, MBeanRegistration {
     
     public void setSendfileThreadCount(int sendfileThreadCount) { endpoint.setSendfileThreadCount(sendfileThreadCount); }
     public int getSendfileThreadCount() { return endpoint.getSendfileThreadCount(); }
-    
+
+    public boolean getDeferAccept() { return endpoint.getDeferAccept(); }
+    public void setDeferAccept(boolean deferAccept) { endpoint.setDeferAccept(deferAccept); }
+
     protected int socketBuffer = 9000;
     public int getSocketBuffer() { return socketBuffer; }
     public void setSocketBuffer(int socketBuffer) { this.socketBuffer = socketBuffer; }
index 9d53b46..57a929a 100644 (file)
@@ -156,15 +156,17 @@ public class AprEndpoint {
     protected long sslContext = 0;
 
     
+    // ------------------------------------------------------------- Properties
+
+
     /**
      * Defer accept.
      */
     protected boolean deferAccept = true;
+    public void setDeferAccept(boolean deferAccept) { this.deferAccept = deferAccept; }
+    public boolean getDeferAccept() { return deferAccept; }
     
 
-    // ------------------------------------------------------------- Properties
-
-
     /**
      * External Executor based thread pool.
      */
@@ -659,8 +661,10 @@ public class AprEndpoint {
         // Delay accepting of new connections until data is available
         // Only Linux kernels 2.4 + have that implemented
         // on other platforms this call is noop and will return APR_ENOTIMPL.
-        if (Socket.optSet(serverSock, Socket.APR_TCP_DEFER_ACCEPT, 1) == Status.APR_ENOTIMPL) {
-            deferAccept = false;
+        if (deferAccept) {
+            if (Socket.optSet(serverSock, Socket.APR_TCP_DEFER_ACCEPT, 1) == Status.APR_ENOTIMPL) {
+                deferAccept = false;
+            }
         }
 
         // Initialize SSL if needed
index 4bd755a..f78e015 100644 (file)
       presented.  The default value is infinite (i.e. no timeout).</p>
     </attribute>
     
+    <attribute name="deferAccept" required="false">
+      <p>Sets the <code>TCP_DEFER_ACCEPT</code> flag on the listening socket for
+      this connector. The default value is <code>true</code> where
+      <code>TCP_DEFER_ACCEPT</code> is supported by the operating system,
+      otherwise it is <code>false</code>.</p>
+    </attribute>
+    
     <attribute name="executor" required="false">
       <p>A reference to the name in an <a href="executor.html">Executor</a> element.
          If this attribute is enabled, and the named executor exists, the connector will