You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2007/03/15 02:31:26 UTC

svn commit: r518430 - /tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java

Author: remm
Date: Wed Mar 14 18:31:26 2007
New Revision: 518430

URL: http://svn.apache.org/viewvc?view=rev&rev=518430
Log:
- When the platform does not support deferred accept, put accepted sockets in the poller (there's a performance penalty,
  of course, but mostly visible for non keep alive connections).

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?view=diff&rev=518430&r1=518429&r2=518430
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Wed Mar 14 18:31:26 2007
@@ -155,6 +155,12 @@
      */
     protected long sslContext = 0;
 
+    
+    /**
+     * Defer accept.
+     */
+    protected boolean deferAccept = true;
+    
 
     // ------------------------------------------------------------- Properties
 
@@ -619,7 +625,6 @@
 
         // Sendfile usage on systems which don't support it cause major problems
         if (useSendfile && !Library.APR_HAS_SENDFILE) {
-            log.warn(sm.getString("endpoint.sendfile.nosupport"));
             useSendfile = false;
         }
 
@@ -655,7 +660,9 @@
         // 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.
-        Socket.optSet(serverSock, Socket.APR_TCP_DEFER_ACCEPT, 1);
+        if (Socket.optSet(serverSock, Socket.APR_TCP_DEFER_ACCEPT, 1) == Status.APR_ENOTIMPL) {
+            deferAccept = false;
+        }
 
         // Initialize SSL if needed
         if (SSLEnabled) {
@@ -1490,16 +1497,27 @@
                 if (socket == 0)
                     continue;
 
-                // Process the request from this socket
-                if ((status != null) && (handler.event(socket, status) == Handler.SocketState.CLOSED)) {
-                    // Close socket and pool
-                    Socket.destroy(socket);
-                    socket = 0;
-                } else if ((status == null) && ((options && !setSocketOptions(socket)) 
-                        || handler.process(socket) == Handler.SocketState.CLOSED)) {
-                    // Close socket and pool
-                    Socket.destroy(socket);
-                    socket = 0;
+                if (!deferAccept && options) {
+                    if (setSocketOptions(socket)) {
+                        getPoller().add(socket);
+                    } else {
+                        // Close socket and pool
+                        Socket.destroy(socket);
+                        socket = 0;
+                    }
+                } else {
+
+                    // Process the request from this socket
+                    if ((status != null) && (handler.event(socket, status) == Handler.SocketState.CLOSED)) {
+                        // Close socket and pool
+                        Socket.destroy(socket);
+                        socket = 0;
+                    } else if ((status == null) && ((options && !setSocketOptions(socket)) 
+                            || handler.process(socket) == Handler.SocketState.CLOSED)) {
+                        // Close socket and pool
+                        Socket.destroy(socket);
+                        socket = 0;
+                    }
                 }
 
                 // Finish up this request
@@ -1904,12 +1922,22 @@
 
         public void run() {
 
-            // Process the request from this socket
-            if (!setSocketOptions(socket) 
-                    || handler.process(socket) == Handler.SocketState.CLOSED) {
-                // Close socket and pool
-                Socket.destroy(socket);
-                socket = 0;
+            if (!deferAccept) {
+                if (setSocketOptions(socket)) {
+                    getPoller().add(socket);
+                } else {
+                    // Close socket and pool
+                    Socket.destroy(socket);
+                    socket = 0;
+                }
+            } else {
+                // Process the request from this socket
+                if (!setSocketOptions(socket) 
+                        || handler.process(socket) == Handler.SocketState.CLOSED) {
+                    // Close socket and pool
+                    Socket.destroy(socket);
+                    socket = 0;
+                }
             }
 
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org