From: remm Date: Thu, 15 Mar 2007 01:31:26 +0000 (+0000) Subject: - When the platform does not support deferred accept, put accepted sockets in the... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=66b3dec9913442038fefcac56f49290c6d565dea;p=tomcat7.0 - 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). git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@518430 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java index d52e0010a..16a174da2 100644 --- a/java/org/apache/tomcat/util/net/AprEndpoint.java +++ b/java/org/apache/tomcat/util/net/AprEndpoint.java @@ -155,6 +155,12 @@ public class AprEndpoint { */ protected long sslContext = 0; + + /** + * Defer accept. + */ + protected boolean deferAccept = true; + // ------------------------------------------------------------- Properties @@ -619,7 +625,6 @@ public class AprEndpoint { // 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 @@ 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. - 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 @@ public class AprEndpoint { 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 class AprEndpoint { 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; + } } }