From 6ba3b5a9eda909ac491f1e74263b3ae8a3505385 Mon Sep 17 00:00:00 2001 From: jfclere Date: Sun, 2 May 2010 10:02:56 +0000 Subject: [PATCH] try to fix async for APR. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@940189 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/coyote/http11/Http11AprProcessor.java | 46 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/java/org/apache/coyote/http11/Http11AprProcessor.java b/java/org/apache/coyote/http11/Http11AprProcessor.java index 4db2a5db7..2bbb27566 100644 --- a/java/org/apache/coyote/http11/Http11AprProcessor.java +++ b/java/org/apache/coyote/http11/Http11AprProcessor.java @@ -924,6 +924,44 @@ public class Http11AprProcessor implements ActionHook { } + /* Copied from the AjpProcessor.java */ + public SocketState asyncDispatch(SocketStatus status) throws IOException { + + RequestInfo rp = request.getRequestProcessor(); + try { + rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE); + error = !adapter.asyncDispatch(request, response, status); + } catch (InterruptedIOException e) { + error = true; + } catch (Throwable t) { + log.error(sm.getString("http11processor.request.process"), t); + // 500 - Internal Server Error + response.setStatus(500); + error = true; + } + + rp.setStage(org.apache.coyote.Constants.STAGE_ENDED); + + if (async) { + if (error) { + response.setStatus(500); + request.updateCounters(); + recycle(); + return SocketState.CLOSED; + } else { + return SocketState.LONG; + } + } else { + if (error) { + response.setStatus(500); + } + request.updateCounters(); + recycle(); + return SocketState.CLOSED; + } + + } + public void endRequest() { @@ -1223,12 +1261,16 @@ public class Http11AprProcessor implements ActionHook { //TODO SERVLET3 - async async = true; } else if (actionCode == ActionCode.ACTION_ASYNC_COMPLETE) { - //TODO SERVLET3 - async + //TODO SERVLET3 - async - that is bit hacky - AtomicBoolean dispatch = (AtomicBoolean)param; RequestInfo rp = request.getRequestProcessor(); if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) { //async handling dispatch.set(true); - // endpoint.processSocket(this.socket, SocketStatus.STOP); + try { + asyncDispatch(SocketStatus.STOP); // What to do with return code ? + } catch (IOException ex) { + error = true; + } } else { dispatch.set(false); } -- 2.11.0