From 866a7ab22375d60a75f117fe8f9806745fa8d406 Mon Sep 17 00:00:00 2001 From: markt Date: Wed, 9 Mar 2011 22:36:55 +0000 Subject: [PATCH] Fix Async with APR and TCP_DEFER_ACCEPT git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1080040 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/tomcat/util/net/AprEndpoint.java | 30 +++++++++++++++++++----- webapps/docs/changelog.xml | 5 ++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java index e0649b4e4..3eb997d56 100644 --- a/java/org/apache/tomcat/util/net/AprEndpoint.java +++ b/java/org/apache/tomcat/util/net/AprEndpoint.java @@ -760,7 +760,8 @@ public class AprEndpoint extends AbstractEndpoint { if (running) { SocketWrapper wrapper = new SocketWrapper(Long.valueOf(socket)); - getExecutor().execute(new SocketWithOptionsProcessor(wrapper)); + getExecutor().execute( + new SocketWithOptionsProcessor(wrapper, null)); } } catch (RejectedExecutionException x) { log.warn("Socket processing request was rejected for:"+socket,x); @@ -1641,9 +1642,13 @@ public class AprEndpoint extends AbstractEndpoint { protected class SocketWithOptionsProcessor implements Runnable { protected SocketWrapper socket = null; + protected SocketStatus status = null; + - public SocketWithOptionsProcessor(SocketWrapper socket) { + public SocketWithOptionsProcessor(SocketWrapper socket, + SocketStatus status) { this.socket = socket; + this.status = status; } @Override @@ -1660,17 +1665,30 @@ public class AprEndpoint extends AbstractEndpoint { } } else { // Process the request from this socket - if (!setSocketOptions(socket.getSocket().longValue()) - || handler.process(socket) == Handler.SocketState.CLOSED) { + if (!setSocketOptions(socket.getSocket().longValue())) { // Close socket and pool destroySocket(socket.getSocket().longValue()); socket = null; } + // Process the request from this socket + Handler.SocketState state = (status==null)?handler.process(socket):handler.asyncDispatch(socket, status); + if (state == Handler.SocketState.CLOSED) { + // Close socket and pool + destroySocket(socket.getSocket().longValue()); + socket = null; + } else if (state == Handler.SocketState.LONG) { + socket.access(); + if (socket.async) { + waitingRequests.add(socket); + } + } else if (state == Handler.SocketState.ASYNC_END) { + socket.access(); + SocketProcessor proc = new SocketProcessor(socket, SocketStatus.OPEN); + getExecutor().execute(proc); + } } } - } - } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index def51e5f0..39a591212 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -90,6 +90,11 @@ 48208: Allow the configuration of a custom trust manager for use in CLIENT-CERT authentication. (markt) + + Fix issues that prevented asynchronous servlets from working when used + with the HTTP APR connector on platforms that support TCP_DEFER_ACCEPT. + (martk) + -- 2.11.0