Author: jfclere Date: Thu May 20 15:42:17 2010 New Revision: 946674 URL: http://svn.apache.org/viewvc?rev=946674&view=rev Log: Arrange APR logic.
Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings_es.properties Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java?rev=946674&r1=946673&r2=946674&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java Thu May 20 15:42:17 2010 @@ -416,6 +416,11 @@ public class AjpAprProtocol return SocketState.CLOSED; } + // FIXME: Support for this could be added in AJP as well + public SocketState asyncDispatch(long socket, SocketStatus status) { + return SocketState.CLOSED; + } + protected AjpAprProcessor createProcessor() { AjpAprProcessor processor = new AjpAprProcessor(proto.packetSize, proto.endpoint); processor.setAdapter(proto.adapter); Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java?rev=946674&r1=946673&r2=946674&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Thu May 20 15:42:17 2010 @@ -926,7 +926,12 @@ public class Http11AprProcessor implemen } /* Copied from the AjpProcessor.java */ - public SocketState asyncDispatch(SocketStatus status) throws IOException { + public SocketState asyncDispatch(long socket, SocketStatus status) throws IOException { + + // Setting up the socket + this.socket = socket; + inputBuffer.setSocket(socket); + outputBuffer.setSocket(socket); RequestInfo rp = request.getRequestProcessor(); try { @@ -1267,11 +1272,7 @@ public class Http11AprProcessor implemen RequestInfo rp = request.getRequestProcessor(); if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) { //async handling dispatch.set(true); - try { - asyncDispatch(SocketStatus.STOP); // What to do with return code ? - } catch (IOException ex) { - error = true; - } + endpoint.getHandler().asyncDispatch(this.socket, SocketStatus.STOP); } else { dispatch.set(false); } Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java?rev=946674&r1=946673&r2=946674&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java Thu May 20 15:42:17 2010 @@ -609,6 +609,47 @@ public class Http11AprProtocol implement return SocketState.CLOSED; } + public SocketState asyncDispatch(long socket, SocketStatus status) { + Http11AprProcessor result = connections.get(Long.valueOf(socket)); + + SocketState state = SocketState.CLOSED; + if (result != null) { + // Call the appropriate event + try { + state = result.asyncDispatch(socket, status); + } catch (java.net.SocketException e) { + // SocketExceptions are normal + Http11AprProtocol.log.debug + (sm.getString + ("http11protocol.proto.socketexception.debug"), e); + } catch (java.io.IOException e) { + // IOExceptions are normal + Http11AprProtocol.log.debug + (sm.getString + ("http11protocol.proto.ioexception.debug"), e); + } + // Future developers: if you discover any other + // rare-but-nonfatal exceptions, catch them here, and log as + // above. + catch (Throwable e) { + // any other exception or error is odd. Here we log it + // with "ERROR" level, so it will show up even on + // less-than-verbose logs. + Http11AprProtocol.log.error + (sm.getString("http11protocol.proto.error"), e); + } finally { + if (state != SocketState.LONG) { + connections.remove(Long.valueOf(socket)); + recycledProcessors.offer(result); + if (state == SocketState.OPEN) { + proto.endpoint.getPoller().add(socket); + } + } + } + } + return state; + } + protected Http11AprProcessor createProcessor() { Http11AprProcessor processor = new Http11AprProcessor(proto.maxHttpHeaderSize, proto.endpoint); Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=946674&r1=946673&r2=946674&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Thu May 20 15:42:17 2010 @@ -38,6 +38,7 @@ import org.apache.tomcat.jni.SSLContext; import org.apache.tomcat.jni.SSLSocket; import org.apache.tomcat.jni.Socket; import org.apache.tomcat.jni.Status; +import org.apache.catalina.core.AprLifecycleListener; /** @@ -368,6 +369,9 @@ public class AprEndpoint extends Abstrac if (initialized) return; + if (!AprLifecycleListener.isAprAvailable()) { + throw new Exception(sm.getString("endpoint.init.notavail"); + } // Create the root APR memory pool rootPool = Pool.create(0); @@ -1403,6 +1407,7 @@ public class AprEndpoint extends Abstrac public interface Handler extends AbstractEndpoint.Handler { public SocketState process(long socket); public SocketState event(long socket, SocketStatus status); + public SocketState asyncDispatch(long socket, SocketStatus status); } @@ -1458,15 +1463,24 @@ public class AprEndpoint extends Abstrac protected class SocketProcessor implements Runnable { protected long socket = 0; + protected boolean async = false; + protected SocketStatus status = SocketStatus.ERROR; public SocketProcessor(long socket) { this.socket = socket; + this.async = false; + } + public SocketProcessor(long socket, boolean asyn, SocketStatus status) { + this.socket = socket; + this.async = asyn; + this.status = status; } public void run() { // Process the request from this socket - if (handler.process(socket) == Handler.SocketState.CLOSED) { + Handler.SocketState state = async?handler.asyncDispatch(socket, status):handler.process(socket); + if (state == Handler.SocketState.CLOSED) { // Close socket and pool Socket.destroy(socket); socket = 0; Modified: tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties?rev=946674&r1=946673&r2=946674&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties Thu May 20 15:42:17 2010 @@ -30,6 +30,7 @@ endpoint.info.maxThreads=Maximum number endpoint.init.bind=Socket bind failed: [{0}] {1} endpoint.init.listen=Socket listen failed: [{0}] {1} +endpoint.init.notavail=APR not available endpoint.accept.fail=Socket accept failed endpoint.poll.limitedpollsize=Failed to create poller with specified size of {0} endpoint.poll.initfail=Poller creation failed @@ -37,6 +38,6 @@ endpoint.poll.fail=Critical poller failu endpoint.poll.error=Unexpected poller error endpoint.process.fail=Error allocating socket processor endpoint.sendfile.error=Unexpected sendfile error -endpoint.sendfile.addfail=Sednfile failure: [{0}] {1} +endpoint.sendfile.addfail=Sendfile failure: [{0}] {1} endpoint.sendfile.nosupport=Disabling sendfile, since either the APR version or the system doesn't support it endpoint.warn.noInsecureReneg=Secure renegotation is not supported by the SSL library {0} Modified: tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings_es.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings_es.properties?rev=946674&r1=946673&r2=946674&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings_es.properties (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings_es.properties Thu May 20 15:42:17 2010 @@ -27,6 +27,7 @@ endpoint.err.close = Excepci\u00F3n cogi endpoint.noProcessor = No hay procesadores - \u00A1hilo de trabajadir muerto\! endpoint.init.bind = Ligado de conector fall\u00F3\: [{0}] {1} endpoint.init.listen = Escucha de conector fall\u00F3\: [{0}] {1} +endpoint.init.notavail = APR no disponible endpoint.accept.fail = Aceptaci\u00F3n de conector fall\u00F3 endpoint.poll.limitedpollsize = No pude crear encuestador de medida espec\u00EDfica de {0} endpoint.poll.initfail = Fall\u00F3 la creaci\u00F3n del encuestador --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org