From a25b414b3373454ff7cd060f44c6c779eab87928 Mon Sep 17 00:00:00 2001 From: rjung Date: Mon, 13 Jun 2011 18:14:46 +0000 Subject: [PATCH] Fix crash observed during pausing the connector when using APR. Only add socket to poller if we are sure we don't close it later. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1135208 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/coyote/ajp/AjpAprProcessor.java | 9 ++------- java/org/apache/coyote/http11/Http11AprProcessor.java | 8 ++++++-- webapps/docs/changelog.xml | 5 +++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/java/org/apache/coyote/ajp/AjpAprProcessor.java b/java/org/apache/coyote/ajp/AjpAprProcessor.java index 783d54a36..32270e808 100644 --- a/java/org/apache/coyote/ajp/AjpAprProcessor.java +++ b/java/org/apache/coyote/ajp/AjpAprProcessor.java @@ -319,13 +319,6 @@ public class AjpAprProcessor extends AbstractAjpProcessor { recycle(); } - // Add the socket to the poller - if (!error && !endpoint.isPaused()) { - if (!isAsync()) { - ((AprEndpoint)endpoint).getPoller().add(socketRef); - } - } - rp.setStage(org.apache.coyote.Constants.STAGE_ENDED); if (error || endpoint.isPaused()) { @@ -333,6 +326,8 @@ public class AjpAprProcessor extends AbstractAjpProcessor { } else if (isAsync()) { return SocketState.LONG; } else { + // Add the socket to the poller + ((AprEndpoint)endpoint).getPoller().add(socketRef); return SocketState.OPEN; } } diff --git a/java/org/apache/coyote/http11/Http11AprProcessor.java b/java/org/apache/coyote/http11/Http11AprProcessor.java index 37fa1b224..2f165977f 100644 --- a/java/org/apache/coyote/http11/Http11AprProcessor.java +++ b/java/org/apache/coyote/http11/Http11AprProcessor.java @@ -212,6 +212,7 @@ public class Http11AprProcessor extends AbstractHttp11Processor { boolean keptAlive = false; boolean openSocket = false; + boolean addToPoller = false; while (!error && keepAlive && !comet && !isAsync() && !endpoint.isPaused()) { @@ -225,14 +226,13 @@ public class Http11AprProcessor extends AbstractHttp11Processor { // (long keepalive), so that the processor should be recycled // and the method should return true openSocket = true; - // Add the socket to the poller - ((AprEndpoint)endpoint).getPoller().add(socketRef); if (endpoint.isPaused()) { // 503 - Service unavailable response.setStatus(503); adapter.log(request, response, 0); error = true; } else { + addToPoller = true; break; } } @@ -350,6 +350,10 @@ public class Http11AprProcessor extends AbstractHttp11Processor { } else if (comet || isAsync()) { return SocketState.LONG; } else { + // Add the socket to the poller + if (addToPoller) { + ((AprEndpoint)endpoint).getPoller().add(socketRef); + } return (openSocket) ? SocketState.OPEN : SocketState.CLOSED; } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index d598de5e2..0d61feb4b 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -57,6 +57,11 @@ Remove superfluous quotes from thread names for connection pools. (rjung) + + Fix crash observed during pausing the connector when using APR. + Only add socket to poller if we are sure we don't close it later. + (rjung) + -- 2.11.0