Author: markt Date: Sun May 15 11:31:49 2011 New Revision: 1103327 URL: http://svn.apache.org/viewvc?rev=1103327&view=rev Log: Get Servlet 3.0 async requests working with new AJP-NIo connector
Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java?rev=1103327&r1=1103326&r2=1103327&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProtocol.java Sun May 15 11:31:49 2011 @@ -17,6 +17,7 @@ package org.apache.coyote.ajp; +import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; @@ -215,7 +216,51 @@ public class AjpNioProtocol extends Abst // FIXME: Support for this could be added in AJP as well @Override public SocketState event(NioChannel socket, SocketStatus status) { - return SocketState.CLOSED; + AjpNioProcessor processor = connections.get(socket); + NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment(false); + att.setAsync(false); //no longer check for timeout + SocketState state = SocketState.CLOSED; + if (processor != null) { + try { + state = processor.asyncDispatch(status); + } + // Future developers: if you discover any other + // rare-but-nonfatal exceptions, catch them here, and log as + // above. + catch (Throwable e) { + ExceptionUtils.handleThrowable(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. + AjpNioProtocol.log.error + (sm.getString("http11protocol.proto.error"), e); + } finally { + if (processor.isAsync()) { + state = processor.asyncPostProcess(); + } + if (state == SocketState.OPEN || state == SocketState.CLOSED) { + release(socket, processor); + if (state == SocketState.OPEN) { + socket.getPoller().add(socket); + } + } else if (state == SocketState.LONG) { + if (processor.isAsync()) { + att.setAsync(true); // Re-enable timeouts + } else { + // Comet + if (log.isDebugEnabled()) log.debug("Keeping processor["+processor); + // May receive more data from client + SelectionKey key = socket.getIOChannel().keyFor(socket.getPoller().getSelector()); + key.interestOps(SelectionKey.OP_READ); + att.interestOps(SelectionKey.OP_READ); + } + } else { + // state == SocketState.ASYNC_END + // No further work required + } + } + } + return state; } @Override --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org