Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Tue Nov 4 11:54:58 2014 @@ -150,12 +150,6 @@ public abstract class AbstractHttp11Proc /** - * Comet used. - */ - protected boolean comet = false; - - - /** * Regular expression that defines the restricted user agents. */ protected Pattern restrictedUserAgents = null; @@ -976,7 +970,6 @@ public abstract class AbstractHttp11Proc // Flags keepAlive = true; - comet = false; openSocket = false; sendfileInProgress = false; readComplete = true; @@ -990,7 +983,7 @@ public abstract class AbstractHttp11Proc socketWrapper.setKeepAliveLeft(0); } - while (!getErrorState().isError() && keepAlive && !comet && !isAsync() && + while (!getErrorState().isError() && keepAlive && !isAsync() && httpUpgradeHandler == null && !endpoint.isPaused()) { // Parsing the request header @@ -1095,7 +1088,6 @@ public abstract class AbstractHttp11Proc statusDropsConnection(response.getStatus())))) { setErrorState(ErrorState.CLOSE_CLEAN, null); } - setCometTimeouts(socketWrapper); } catch (InterruptedIOException e) { setErrorState(ErrorState.CLOSE_NOW, e); } catch (HeadersTooLargeException e) { @@ -1123,7 +1115,7 @@ public abstract class AbstractHttp11Proc // Finish the handling of the request rp.setStage(org.apache.coyote.Constants.STAGE_ENDINPUT); - if (!isAsync() && !comet) { + if (!isAsync()) { if (getErrorState().isError()) { // If we know we are closing the connection, don't drain // input. This way uploading a 100GB file doesn't tie up the @@ -1152,7 +1144,7 @@ public abstract class AbstractHttp11Proc } request.updateCounters(); - if (!isAsync() && !comet || getErrorState().isError()) { + if (!isAsync() || getErrorState().isError()) { if (getErrorState().isIoAllowed()) { getInputBuffer().nextRequest(); getOutputBuffer().nextRequest(); @@ -1178,7 +1170,7 @@ public abstract class AbstractHttp11Proc if (getErrorState().isError() || endpoint.isPaused()) { return SocketState.CLOSED; - } else if (isAsync() || comet) { + } else if (isAsync()) { return SocketState.LONG; } else if (isUpgrade()) { return SocketState.UPGRADING; @@ -1711,12 +1703,6 @@ public abstract class AbstractHttp11Proc @Override - public boolean isComet() { - return comet; - } - - - @Override public boolean isUpgrade() { return httpUpgradeHandler != null; } @@ -1745,12 +1731,6 @@ public abstract class AbstractHttp11Proc protected abstract void resetTimeouts(); - /** - * Provides a mechanism for those connectors (currently only NIO) that need - * that need to set comet timeouts. - */ - protected abstract void setCometTimeouts(SocketWrapper<S> socketWrapper); - public void endRequest() { // Finish the handling of the request @@ -1807,7 +1787,6 @@ public abstract class AbstractHttp11Proc asyncStateMachine.recycle(); } httpUpgradeHandler = null; - comet = false; resetErrorState(); recycleInternal(); }
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=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Tue Nov 4 11:54:58 2014 @@ -18,13 +18,11 @@ package org.apache.coyote.http11; import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.InterruptedIOException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import org.apache.coyote.ActionCode; import org.apache.coyote.ErrorState; -import org.apache.coyote.RequestInfo; import org.apache.coyote.http11.filters.BufferedInputFilter; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; @@ -33,11 +31,8 @@ import org.apache.tomcat.jni.SSL; import org.apache.tomcat.jni.SSLSocket; import org.apache.tomcat.jni.Sockaddr; import org.apache.tomcat.jni.Socket; -import org.apache.tomcat.util.ExceptionUtils; -import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; import org.apache.tomcat.util.net.AprEndpoint; import org.apache.tomcat.util.net.SSLSupport; -import org.apache.tomcat.util.net.SocketStatus; import org.apache.tomcat.util.net.SocketWrapper; @@ -98,47 +93,6 @@ public class Http11AprProcessor extends // --------------------------------------------------------- Public Methods - /** - * Process pipelined HTTP requests using the specified input and output - * streams. - * - * @throws IOException error during an I/O operation - */ - @Override - public SocketState event(SocketStatus status) - throws IOException { - - RequestInfo rp = request.getRequestProcessor(); - - try { - rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE); - if (!getAdapter().event(request, response, status)) { - setErrorState(ErrorState.CLOSE_NOW, null); - } - } catch (InterruptedIOException e) { - setErrorState(ErrorState.CLOSE_NOW, e); - } catch (Throwable t) { - ExceptionUtils.handleThrowable(t); - // 500 - Internal Server Error - response.setStatus(500); - setErrorState(ErrorState.CLOSE_NOW, t); - getAdapter().log(request, response, 0); - log.error(sm.getString("http11processor.request.process"), t); - } - - rp.setStage(org.apache.coyote.Constants.STAGE_ENDED); - - if (getErrorState().isError() || status==SocketStatus.STOP) { - return SocketState.CLOSED; - } else if (!comet) { - inputBuffer.nextRequest(); - outputBuffer.nextRequest(); - return SocketState.OPEN; - } else { - return SocketState.LONG; - } - } - @Override protected boolean disableKeepAlive() { return false; @@ -186,12 +140,6 @@ public class Http11AprProcessor extends @Override - protected void setCometTimeouts(SocketWrapper<Long> socketWrapper) { - // NO-OP for APR/native - } - - - @Override protected boolean breakKeepAliveLoop(SocketWrapper<Long> socketWrapper) { openSocket = keepAlive; // Do sendfile as needed: add socket to sendfile and end @@ -455,23 +403,6 @@ public class Http11AprProcessor extends } break; } - case COMET_BEGIN: { - comet = true; - break; - } - case COMET_END: { - comet = false; - break; - } - case COMET_CLOSE: { - ((AprEndpoint)endpoint).processSocket(this.socketWrapper, - SocketStatus.OPEN_READ, true); - break; - } - case COMET_SETTIMEOUT: { - //no op - break; - } } } 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=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java Tue Nov 4 11:54:58 2014 @@ -266,7 +266,7 @@ public class Http11AprProtocol extends A } if (processor == null) { - // if not null - this is a former comet request, handled by http11 + // if not null - handled by http11 SocketState socketState = proto.npnHandler.process(socket, status); // handled by npn protocol. if (socketState == SocketState.CLOSED || @@ -291,19 +291,6 @@ public class Http11AprProtocol extends A if (processor.isAsync()) { // Async socket.setAsync(true); - } else if (processor.isComet()) { - // Comet - if (proto.endpoint.isRunning()) { - socket.setComet(true); - ((AprEndpoint) proto.endpoint).getPoller().add( - socket.getSocket().longValue(), - proto.endpoint.getSoTimeout(), true, false); - } else { - // Process a STOP directly - ((AprEndpoint) proto.endpoint).processSocket( - socket.getSocket().longValue(), - SocketStatus.STOP); - } } else { // Upgraded Poller p = ((AprEndpoint) proto.endpoint).getPoller(); Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java Tue Nov 4 11:54:58 2014 @@ -17,7 +17,6 @@ package org.apache.coyote.http11; import java.io.IOException; -import java.io.InterruptedIOException; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -25,11 +24,9 @@ import javax.net.ssl.SSLEngine; import org.apache.coyote.ActionCode; import org.apache.coyote.ErrorState; -import org.apache.coyote.RequestInfo; import org.apache.coyote.http11.filters.BufferedInputFilter; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; -import org.apache.tomcat.util.ExceptionUtils; import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; import org.apache.tomcat.util.net.Nio2Channel; import org.apache.tomcat.util.net.Nio2Endpoint; @@ -85,72 +82,6 @@ public class Http11Nio2Processor extends // --------------------------------------------------------- Public Methods @Override - public SocketState event(SocketStatus status) - throws IOException { - - long soTimeout = endpoint.getSoTimeout(); - - RequestInfo rp = request.getRequestProcessor(); - try { - rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE); - if (!getAdapter().event(request, response, status)) { - setErrorState(ErrorState.CLOSE_NOW, null); - } - if (!getErrorState().isError()) { - if (socketWrapper != null) { - socketWrapper.setComet(comet); - if (comet) { - Integer comettimeout = (Integer) request.getAttribute( - org.apache.coyote.Constants.COMET_TIMEOUT_ATTR); - if (comettimeout != null) { - socketWrapper.setTimeout(comettimeout.longValue()); - } - } else { - //reset the timeout - if (keepAlive) { - socketWrapper.setTimeout(keepAliveTimeout); - } else { - socketWrapper.setTimeout(soTimeout); - } - } - - } - } - } catch (InterruptedIOException e) { - setErrorState(ErrorState.CLOSE_NOW, e); - } catch (Throwable t) { - ExceptionUtils.handleThrowable(t); - // 500 - Internal Server Error - response.setStatus(500); - setErrorState(ErrorState.CLOSE_NOW, t); - getAdapter().log(request, response, 0); - log.error(sm.getString("http11processor.request.process"), t); - } - - rp.setStage(org.apache.coyote.Constants.STAGE_ENDED); - - if (getErrorState().isError() || status==SocketStatus.STOP) { - return SocketState.CLOSED; - } else if (!comet) { - if (keepAlive) { - inputBuffer.nextRequest(); - outputBuffer.nextRequest(); - if (((InternalNio2InputBuffer) inputBuffer).isPending()) { - // Following comet processing, a read is still pending, so - // keep the processor associated - return SocketState.LONG; - } else { - return SocketState.OPEN; - } - } else { - return SocketState.CLOSED; - } - } else { - return SocketState.LONG; - } - } - - @Override public SocketState asyncDispatch(SocketStatus status) { SocketState state = super.asyncDispatch(status); if (state == SocketState.OPEN && ((InternalNio2InputBuffer) inputBuffer).isPending()) { @@ -258,21 +189,6 @@ public class Http11Nio2Processor extends @Override - protected void setCometTimeouts(SocketWrapper<Nio2Channel> socketWrapper) { - if (socketWrapper != null) { - socketWrapper.setComet(comet); - if (comet) { - Integer comettimeout = (Integer) request.getAttribute( - org.apache.coyote.Constants.COMET_TIMEOUT_ATTR); - if (comettimeout != null) { - socketWrapper.setTimeout(comettimeout.longValue()); - } - } - } - } - - - @Override protected boolean breakKeepAliveLoop( SocketWrapper<Nio2Channel> socketWrapper) { openSocket = keepAlive; @@ -503,42 +419,6 @@ public class Http11Nio2Processor extends } break; } - case COMET_BEGIN: { - comet = true; - break; - } - case COMET_END: { - comet = false; - break; - } - case COMET_CLOSE: { - if (socketWrapper == null || socketWrapper.getSocket() == null) { - return; - } - RequestInfo rp = request.getRequestProcessor(); - if (rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE) { - // Close event for this processor triggered by request - // processing in another processor, a non-Tomcat thread (i.e. - // an application controlled thread) or similar. - endpoint.processSocket(this.socketWrapper, SocketStatus.OPEN_READ, true); - } - break; - } - case COMET_SETTIMEOUT: { - if (param == null) { - return; - } - if (socketWrapper == null) { - return; - } - long timeout = ((Long)param).longValue(); - //if we are not piggy backing on a worker thread, set the timeout - RequestInfo rp = request.getRequestProcessor(); - if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) { - socketWrapper.setTimeout(timeout); - } - break; - } } } Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Protocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Protocol.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Protocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Protocol.java Tue Nov 4 11:54:58 2014 @@ -236,7 +236,6 @@ public class Http11Nio2Protocol extends } } else { // Either: - // - this is comet request // - this is an upgraded connection // - the request line/headers have not been completely // read @@ -275,7 +274,7 @@ public class Http11Nio2Protocol extends @Override public void closeAll() { for (Nio2Channel channel : connections.keySet()) { - ((Nio2Endpoint) proto.endpoint).closeSocket(channel.getSocket(), SocketStatus.STOP); + ((Nio2Endpoint) proto.endpoint).closeSocket(channel.getSocket()); } } } Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Tue Nov 4 11:54:58 2014 @@ -17,7 +17,6 @@ package org.apache.coyote.http11; import java.io.IOException; -import java.io.InterruptedIOException; import java.net.InetAddress; import java.nio.channels.SelectionKey; @@ -25,18 +24,14 @@ import javax.net.ssl.SSLEngine; import org.apache.coyote.ActionCode; import org.apache.coyote.ErrorState; -import org.apache.coyote.RequestInfo; import org.apache.coyote.http11.filters.BufferedInputFilter; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; -import org.apache.tomcat.util.ExceptionUtils; -import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; import org.apache.tomcat.util.net.NioChannel; import org.apache.tomcat.util.net.NioEndpoint; import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; import org.apache.tomcat.util.net.SSLSupport; import org.apache.tomcat.util.net.SecureNioChannel; -import org.apache.tomcat.util.net.SocketStatus; import org.apache.tomcat.util.net.SocketWrapper; @@ -87,73 +82,6 @@ public class Http11NioProcessor extends // --------------------------------------------------------- Public Methods - /** - * Process pipelined HTTP requests using the specified input and output - * streams. - * - * @throws IOException error during an I/O operation - */ - @Override - public SocketState event(SocketStatus status) throws IOException { - - long soTimeout = endpoint.getSoTimeout(); - - RequestInfo rp = request.getRequestProcessor(); - final NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment)socketWrapper.getSocket().getAttachment(false); - try { - rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE); - if (!getAdapter().event(request, response, status)) { - setErrorState(ErrorState.CLOSE_NOW, null); - } - if (!getErrorState().isError()) { - if (attach != null) { - attach.setComet(comet); - if (comet) { - Integer comettimeout = (Integer) request.getAttribute( - org.apache.coyote.Constants.COMET_TIMEOUT_ATTR); - if (comettimeout != null) { - attach.setTimeout(comettimeout.longValue()); - } - } else { - //reset the timeout - if (keepAlive) { - attach.setTimeout(keepAliveTimeout); - } else { - attach.setTimeout(soTimeout); - } - } - - } - } - } catch (InterruptedIOException e) { - setErrorState(ErrorState.CLOSE_NOW, e); - } catch (Throwable t) { - ExceptionUtils.handleThrowable(t); - // 500 - Internal Server Error - response.setStatus(500); - setErrorState(ErrorState.CLOSE_NOW, t); - log.error(sm.getString("http11processor.request.process"), t); - getAdapter().log(request, response, 0); - } - - rp.setStage(org.apache.coyote.Constants.STAGE_ENDED); - - if (getErrorState().isError() || status==SocketStatus.STOP) { - return SocketState.CLOSED; - } else if (!comet) { - if (keepAlive) { - inputBuffer.nextRequest(); - outputBuffer.nextRequest(); - return SocketState.OPEN; - } else { - return SocketState.CLOSED; - } - } else { - return SocketState.LONG; - } - } - - @Override protected void registerForEvent(boolean read, boolean write) { final NioChannel socket = socketWrapper.getSocket(); @@ -251,27 +179,6 @@ public class Http11NioProcessor extends @Override - protected void setCometTimeouts(SocketWrapper<NioChannel> socketWrapper) { - // Comet support - SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor( - socketWrapper.getSocket().getPoller().getSelector()); - if (key != null) { - NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment) key.attachment(); - if (attach != null) { - attach.setComet(comet); - if (comet) { - Integer comettimeout = (Integer) request.getAttribute( - org.apache.coyote.Constants.COMET_TIMEOUT_ATTR); - if (comettimeout != null) { - attach.setTimeout(comettimeout.longValue()); - } - } - } - } - } - - - @Override protected boolean breakKeepAliveLoop(SocketWrapper<NioChannel> socketWrapper) { openSocket = keepAlive; // Do sendfile as needed: add socket to sendfile and end @@ -472,43 +379,6 @@ public class Http11NioProcessor extends } break; } - case COMET_BEGIN: { - comet = true; - break; - } - case COMET_END: { - comet = false; - break; - } - case COMET_CLOSE: { - if (socketWrapper==null || socketWrapper.getSocket().getAttachment(false)==null) { - return; - } - RequestInfo rp = request.getRequestProcessor(); - if (rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE) { - // Close event for this processor triggered by request - // processing in another processor, a non-Tomcat thread (i.e. - // an application controlled thread) or similar. - socketWrapper.getSocket().getPoller().add(socketWrapper.getSocket()); - } - break; - } - case COMET_SETTIMEOUT: { - if (param==null) { - return; - } - if (socketWrapper==null || socketWrapper.getSocket().getAttachment(false)==null) { - return; - } - NioEndpoint.KeyAttachment attach = (NioEndpoint.KeyAttachment)socketWrapper.getSocket().getAttachment(false); - long timeout = ((Long)param).longValue(); - //if we are not piggy backing on a worker thread, set the timeout - RequestInfo rp = request.getRequestProcessor(); - if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) { - attach.setTimeout(timeout); - } - break; - } } } Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java Tue Nov 4 11:54:58 2014 @@ -269,7 +269,6 @@ public class Http11NioProtocol extends A socket.setAsync(true); } else { // Either: - // - this is comet request // - this is an upgraded connection // - the request line/headers have not been completely // read Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Tue Nov 4 11:54:58 2014 @@ -25,10 +25,8 @@ import org.apache.coyote.ActionCode; import org.apache.coyote.http11.filters.BufferedInputFilter; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; -import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState; import org.apache.tomcat.util.net.JIoEndpoint; import org.apache.tomcat.util.net.SSLSupport; -import org.apache.tomcat.util.net.SocketStatus; import org.apache.tomcat.util.net.SocketWrapper; @@ -179,12 +177,6 @@ public class Http11Processor extends Abs @Override - protected void setCometTimeouts(SocketWrapper<Socket> socketWrapper) { - // NO-OP for BIO - } - - - @Override protected boolean breakKeepAliveLoop(SocketWrapper<Socket> socketWrapper) { openSocket = keepAlive; // If we don't have a pipe-lined request allow this thread to be @@ -216,16 +208,8 @@ public class Http11Processor extends Abs } - @Override - public SocketState event(SocketStatus status) throws IOException { - // Should never reach this code but in case we do... - throw new IOException( - sm.getString("http11processor.comet.notsupported")); - } - // ----------------------------------------------------- ActionHook Methods - /** * Send an action to the connector. * Modified: tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties Tue Nov 4 11:54:58 2014 @@ -23,7 +23,6 @@ http11processor.response.finish=Error fi http11processor.socket.info=Exception getting socket information http11processor.socket.ssl=Exception getting SSL attributes http11processor.socket.sslreneg=Exception re-negotiating SSL connection -http11processor.comet.notsupported=The Comet protocol is not supported by this connector http11processor.sendfile.error=Error sending data using sendfile. May be caused by invalid request attributes for start/end points http11Processor.upgrade=An internal error has occurred as upgraded connections should only be processed by the dedicated upgrade processor implementations Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java Tue Nov 4 11:54:58 2014 @@ -141,11 +141,6 @@ public abstract class AbstractProcessor< } @Override - public final SocketState event(SocketStatus status) throws IOException { - return null; - } - - @Override public final SocketState asyncDispatch(SocketStatus status) { return null; } @@ -161,11 +156,6 @@ public abstract class AbstractProcessor< } @Override - public final boolean isComet() { - return false; - } - - @Override public final boolean isAsync() { return false; } Modified: tomcat/trunk/java/org/apache/coyote/spdy/SpdyProcessor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/spdy/SpdyProcessor.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/spdy/SpdyProcessor.java (original) +++ tomcat/trunk/java/org/apache/coyote/spdy/SpdyProcessor.java Tue Nov 4 11:54:58 2014 @@ -507,23 +507,12 @@ public class SpdyProcessor<S> extends Ab } @Override - public boolean isComet() { - return false; - } - - @Override public SocketState process(SocketWrapper<S> socket) throws IOException { throw new IOException("Unimplemented"); } @Override - public SocketState event(SocketStatus status) throws IOException { - System.err.println("EVENT: " + status); - return null; - } - - @Override public SocketState asyncDispatch(SocketStatus status) { System.err.println("ASYNC DISPATCH: " + status); return null; Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Tue Nov 4 11:54:58 2014 @@ -821,8 +821,6 @@ public abstract class AbstractEndpoint<S // Some of these are always hard-coded, some are hard-coded to false (i.e. // the endpoint does not support them) and some are configurable. public abstract boolean getUseSendfile(); - public abstract boolean getUseComet(); - public abstract boolean getUseCometTimeout(); public abstract boolean getUsePolling(); protected LimitLatch initializeConnectionLatch() { 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=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Tue Nov 4 11:54:58 2014 @@ -159,15 +159,6 @@ public class AprEndpoint extends Abstrac public boolean getUseSendfile() { return useSendfile; } - /** - * Allow comet request handling. - */ - protected boolean useComet = true; - public void setUseComet(boolean useComet) { this.useComet = useComet; } - @Override - public boolean getUseComet() { return useComet; } - @Override - public boolean getUseCometTimeout() { return false; } // Not supported @Override public boolean getUsePolling() { return true; } // Always supported @@ -857,8 +848,7 @@ public class AprEndpoint extends Abstrac /** - * Process given socket. Called in non-comet mode, typically keep alive - * or upgraded protocol. + * Process given socket. Typically keep alive or upgraded protocol. */ public boolean processSocket(long socket, SocketStatus status) { try { @@ -1405,14 +1395,9 @@ public class AprEndpoint extends Abstrac // Close all sockets in the add queue SocketInfo info = addList.get(); while (info != null) { - boolean comet = - connections.get(Long.valueOf(info.socket)).isComet(); - if (!comet || (comet && !processSocket( - info.socket, SocketStatus.STOP))) { - // Poller isn't running at this point so use destroySocket() - // directly - destroySocket(info.socket); - } + // Poller isn't running at this point so use destroySocket() + // directly + destroySocket(info.socket); info = addList.get(); } addList.clear(); @@ -1421,12 +1406,7 @@ public class AprEndpoint extends Abstrac int rv = Poll.pollset(pollers[i], desc); if (rv > 0) { for (int n = 0; n < rv; n++) { - boolean comet = connections.get( - Long.valueOf(desc[n*2+1])).isComet(); - if (!comet || (comet && !processSocket( - desc[n*2+1], SocketStatus.STOP))) { - destroySocket(desc[n*2+1]); - } + destroySocket(desc[n*2+1]); } } } @@ -1483,12 +1463,7 @@ public class AprEndpoint extends Abstrac } if (!ok) { // Can't do anything: close the socket right away - boolean comet = connections.get( - Long.valueOf(socket)).isComet(); - if (!comet || (comet && !processSocket( - socket, SocketStatus.ERROR))) { - closeSocket(socket); - } + closeSocket(socket); } } @@ -1576,12 +1551,7 @@ public class AprEndpoint extends Abstrac Long.valueOf(socket))); } removeFromPoller(socket); - boolean comet = connections.get( - Long.valueOf(socket)).isComet(); - if (!comet || (comet && !processSocket( - socket, SocketStatus.TIMEOUT))) { - destroySocket(socket); - } + destroySocket(socket); socket = timeouts.check(date); } @@ -1703,20 +1673,11 @@ public class AprEndpoint extends Abstrac continue; } if (info.read() || info.write()) { - boolean comet = wrapper.isComet(); - if (comet || wrapper.pollerFlags != 0) { - removeFromPoller(info.socket); - } wrapper.pollerFlags = wrapper.pollerFlags | (info.read() ? Poll.APR_POLLIN : 0) | (info.write() ? Poll.APR_POLLOUT : 0); if (!addToPoller(info.socket, wrapper.pollerFlags)) { - // Can't do anything: close the socket right - // away - if (!comet || (comet && !processSocket( - info.socket, SocketStatus.ERROR))) { - closeSocket(info.socket); - } + closeSocket(info.socket); } else { timeouts.add(info.socket, System.currentTimeMillis() + @@ -1770,42 +1731,7 @@ public class AprEndpoint extends Abstrac } wrapper.pollerFlags = wrapper.pollerFlags & ~((int) desc[n*2]); // Check for failed sockets and hand this socket off to a worker - if (wrapper.isComet()) { - // Event processes either a read or a write depending on what the poller returns - if (((desc[n*2] & Poll.APR_POLLHUP) == Poll.APR_POLLHUP) - || ((desc[n*2] & Poll.APR_POLLERR) == Poll.APR_POLLERR) - || ((desc[n*2] & Poll.APR_POLLNVAL) == Poll.APR_POLLNVAL)) { - if (!processSocket(desc[n*2+1], SocketStatus.ERROR)) { - // Close socket and clear pool - closeSocket(desc[n*2+1]); - } - } else if ((desc[n*2] & Poll.APR_POLLIN) == Poll.APR_POLLIN) { - if (wrapper.pollerFlags != 0) { - add(desc[n*2+1], 1, wrapper.pollerFlags); - } - if (!processSocket(desc[n*2+1], SocketStatus.OPEN_READ)) { - // Close socket and clear pool - closeSocket(desc[n*2+1]); - } - } else if ((desc[n*2] & Poll.APR_POLLOUT) == Poll.APR_POLLOUT) { - if (wrapper.pollerFlags != 0) { - add(desc[n*2+1], 1, wrapper.pollerFlags); - } - if (!processSocket(desc[n*2+1], SocketStatus.OPEN_WRITE)) { - // Close socket and clear pool - closeSocket(desc[n*2+1]); - } - } else { - // Unknown event - getLog().warn(sm.getString( - "endpoint.apr.pollUnknownEvent", - Long.valueOf(desc[n*2]))); - if (!processSocket(desc[n*2+1], SocketStatus.ERROR)) { - // Close socket and clear pool - closeSocket(desc[n*2+1]); - } - } - } else if (((desc[n*2] & Poll.APR_POLLHUP) == Poll.APR_POLLHUP) + if (((desc[n*2] & Poll.APR_POLLHUP) == Poll.APR_POLLHUP) || ((desc[n*2] & Poll.APR_POLLERR) == Poll.APR_POLLERR) || ((desc[n*2] & Poll.APR_POLLNVAL) == Poll.APR_POLLNVAL)) { if (wrapper.isAsync() || wrapper.isUpgraded()) { Modified: tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Tue Nov 4 11:54:58 2014 @@ -118,10 +118,6 @@ public class JIoEndpoint extends Abstrac @Override public boolean getUseSendfile() { return false; } // Not supported @Override - public boolean getUseComet() { return false; } // Not supported - @Override - public boolean getUseCometTimeout() { return false; } // Not supported - @Override public boolean getDeferAccept() { return false; } // Not supported @Override public boolean getUsePolling() { return false; } // Not supported Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Tue Nov 4 11:54:58 2014 @@ -151,15 +151,6 @@ public class Nio2Endpoint extends Abstra public Handler getHandler() { return handler; } - /** - * Allow comet request handling. - */ - private boolean useComet = true; - public void setUseComet(boolean useComet) { this.useComet = useComet; } - @Override - public boolean getUseComet() { return useComet; } - @Override - public boolean getUseCometTimeout() { return getUseComet(); } @Override public boolean getUsePolling() { return true; } // Always supported @@ -610,22 +601,11 @@ public class Nio2Endpoint extends Abstra return true; } - public void closeSocket(SocketWrapper<Nio2Channel> socket, SocketStatus status) { + public void closeSocket(SocketWrapper<Nio2Channel> socket) { if (socket == null) { return; } try { - if (socket.isComet() && status != null) { - socket.setComet(false);//to avoid a loop - if (status == SocketStatus.TIMEOUT) { - if (processSocket0(socket, status, true)) { - return; // don't close on comet timeout - } - } else { - // Don't dispatch if the lines below are canceling the key - processSocket0(socket, status, false); - } - } handler.release(socket); try { if (socket.getSocket() != null) { @@ -1088,8 +1068,7 @@ public class Nio2Endpoint extends Abstra } if (state == SocketState.CLOSED) { // Close socket and pool - socket.setComet(false); - closeSocket(socket, SocketStatus.ERROR); + closeSocket(socket); if (useCaches && running && !paused) { nioChannels.push(socket.getSocket()); socketWrapperCache.push((Nio2SocketWrapper) socket); @@ -1100,7 +1079,7 @@ public class Nio2Endpoint extends Abstra launch = true; } } else if (handshake == -1 ) { - closeSocket(socket, SocketStatus.DISCONNECT); + closeSocket(socket); if (useCaches && running && !paused) { nioChannels.push(socket.getSocket()); socketWrapperCache.push(((Nio2SocketWrapper) socket)); @@ -1110,7 +1089,7 @@ public class Nio2Endpoint extends Abstra try { oomParachuteData = null; log.error("", oom); - closeSocket(socket, SocketStatus.ERROR); + closeSocket(socket); releaseCaches(); } catch (Throwable oomt) { try { @@ -1125,7 +1104,7 @@ public class Nio2Endpoint extends Abstra } catch (Throwable t) { log.error(sm.getString("endpoint.processing.fail"), t); if (socket != null) { - closeSocket(socket, SocketStatus.ERROR); + closeSocket(socket); } } finally { if (launch) { Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Tue Nov 4 11:54:58 2014 @@ -183,15 +183,6 @@ public class NioEndpoint extends Abstrac public Handler getHandler() { return handler; } - /** - * Allow comet request handling. - */ - private boolean useComet = true; - public void setUseComet(boolean useComet) { this.useComet = useComet; } - @Override - public boolean getUseComet() { return useComet; } - @Override - public boolean getUseCometTimeout() { return getUseComet(); } @Override public boolean getUsePolling() { return true; } // Always supported @@ -618,7 +609,6 @@ public class NioEndpoint extends Abstrac if (attachment == null) { return false; } - attachment.setCometNotify(false); //will get reset upon next reg SocketProcessor sc = processorCache.pop(); if ( sc == null ) sc = new SocketProcessor(attachment, status); else sc.reset(attachment, status); @@ -801,28 +791,22 @@ public class NioEndpoint extends Abstrac final KeyAttachment att = (KeyAttachment) key.attachment(); if ( att!=null ) { //handle callback flag - if ((interestOps & OP_CALLBACK) == OP_CALLBACK ) { - att.setCometNotify(true); - } else { - att.setCometNotify(false); - } interestOps = (interestOps & (~OP_CALLBACK));//remove the callback flag att.access();//to prevent timeout //we are registering the key to start with, reset the fairness counter. int ops = key.interestOps() | interestOps; att.interestOps(ops); - if (att.getCometNotify()) key.interestOps(0); - else key.interestOps(ops); + key.interestOps(ops); } else { cancel = true; } } else { cancel = true; } - if ( cancel ) socket.getPoller().cancelledKey(key,SocketStatus.ERROR); + if ( cancel ) socket.getPoller().cancelledKey(key); }catch (CancelledKeyException ckx) { try { - socket.getPoller().cancelledKey(key,SocketStatus.DISCONNECT); + socket.getPoller().cancelledKey(key); }catch (Exception ignore) {} } }//end if @@ -950,21 +934,10 @@ public class NioEndpoint extends Abstrac addEvent(r); } - public void cancelledKey(SelectionKey key, SocketStatus status) { + public void cancelledKey(SelectionKey key) { try { if ( key == null ) return;//nothing to do KeyAttachment ka = (KeyAttachment) key.attachment(); - if (ka != null && ka.isComet() && status != null) { - ka.setComet(false);//to avoid a loop - if (status == SocketStatus.TIMEOUT ) { - if (processSocket(ka, status, true)) { - return; // don't close on comet timeout - } - } else { - // Don't dispatch if the lines below are canceling the key - processSocket(ka, status, false); - } - } key.attach(null); if (ka!=null) handler.release(ka); else handler.release((SocketChannel)key.channel()); @@ -1114,7 +1087,7 @@ public class NioEndpoint extends Abstrac boolean result = true; try { if ( close ) { - cancelledKey(sk, SocketStatus.STOP); + cancelledKey(sk); } else if ( sk.isValid() && attachment != null ) { attachment.access();//make sure we don't time out valid sockets if (sk.isReadable() || sk.isWritable() ) { @@ -1136,7 +1109,7 @@ public class NioEndpoint extends Abstrac } } if (closeSocket) { - cancelledKey(sk,SocketStatus.DISCONNECT); + cancelledKey(sk); } } else { result = false; @@ -1145,10 +1118,10 @@ public class NioEndpoint extends Abstrac } } else { //invalid key - cancelledKey(sk, SocketStatus.ERROR); + cancelledKey(sk); } } catch ( CancelledKeyException ckx ) { - cancelledKey(sk, SocketStatus.ERROR); + cancelledKey(sk); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.error("",t); @@ -1170,7 +1143,7 @@ public class NioEndpoint extends Abstrac if ( sd.fchannel == null ) { File f = new File(sd.fileName); if ( !f.exists() ) { - cancelledKey(sk,SocketStatus.ERROR); + cancelledKey(sk); return false; } @SuppressWarnings("resource") // Closed when channel is closed @@ -1226,7 +1199,7 @@ public class NioEndpoint extends Abstrac if (log.isDebugEnabled()) { log.debug("Send file connection is being closed"); } - cancelledKey(sk,SocketStatus.STOP); + cancelledKey(sk); return false; } } else { @@ -1241,11 +1214,11 @@ public class NioEndpoint extends Abstrac } }catch ( IOException x ) { if ( log.isDebugEnabled() ) log.debug("Unable to complete sendfile request:", x); - cancelledKey(sk,SocketStatus.ERROR); + cancelledKey(sk); return false; }catch ( Throwable t ) { log.error("",t); - cancelledKey(sk, SocketStatus.ERROR); + cancelledKey(sk); return false; }finally { if (sc!=null) sc.setSendFile(false); @@ -1284,15 +1257,9 @@ public class NioEndpoint extends Abstrac try { KeyAttachment ka = (KeyAttachment) key.attachment(); if ( ka == null ) { - cancelledKey(key, SocketStatus.ERROR); //we don't support any keys without attachments + cancelledKey(key); //we don't support any keys without attachments } else if ( ka.getError() ) { - cancelledKey(key, SocketStatus.ERROR);//TODO this is not yet being used - } else if (ka.getCometNotify() ) { - ka.setCometNotify(false); - int ops = ka.interestOps() & ~OP_CALLBACK; - reg(key,ka,0);//avoid multiple calls, this gets re-registered after invocation - ka.interestOps(ops); - if (!processSocket(ka, SocketStatus.OPEN_READ, true)) processSocket(ka, SocketStatus.DISCONNECT, true); + cancelledKey(key);//TODO this is not yet being used } else if ((ka.interestOps()&SelectionKey.OP_READ) == SelectionKey.OP_READ || (ka.interestOps()&SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) { //only timeout sockets that we are waiting for a read from @@ -1306,9 +1273,9 @@ public class NioEndpoint extends Abstrac } else if (isTimedout) { key.interestOps(0); ka.interestOps(0); //avoid duplicate timeout calls - cancelledKey(key, SocketStatus.TIMEOUT); + cancelledKey(key); } - } else if (ka.isAsync() || ka.isComet()) { + } else if (ka.isAsync()) { if (close) { key.interestOps(0); ka.interestOps(0); //avoid duplicate stop calls @@ -1326,7 +1293,7 @@ public class NioEndpoint extends Abstrac } }//end if }catch ( CancelledKeyException ckx ) { - cancelledKey(key, SocketStatus.ERROR); + cancelledKey(key); } }//for long prevExp = nextExpiration; //for logging purposes only @@ -1352,7 +1319,6 @@ public class NioEndpoint extends Abstrac public void reset(Poller poller, NioChannel channel, long soTimeout) { super.reset(channel, soTimeout); - cometNotify = false; interestOps = 0; this.poller = poller; sendfileData = null; @@ -1384,8 +1350,6 @@ public class NioEndpoint extends Abstrac public Poller getPoller() { return poller;} public void setPoller(Poller poller){this.poller = poller;} - public void setCometNotify(boolean notify) { this.cometNotify = notify; } - public boolean getCometNotify() { return cometNotify; } public int interestOps() { return interestOps;} public int interestOps(int ops) { this.interestOps = ops; return ops; } public CountDownLatch getReadLatch() { return readLatch; } @@ -1426,7 +1390,6 @@ public class NioEndpoint extends Abstrac private Poller poller = null; private int interestOps = 0; - private boolean cometNotify = false; private CountDownLatch readLatch = null; private CountDownLatch writeLatch = null; private SendfileData sendfileData = null; @@ -1558,8 +1521,7 @@ public class NioEndpoint extends Abstrac if (state == SocketState.CLOSED) { // Close socket and pool try { - ka.setComet(false); - socket.getPoller().cancelledKey(key, SocketStatus.ERROR); + socket.getPoller().cancelledKey(key); if (running && !paused) { nioChannels.push(socket); } @@ -1577,7 +1539,7 @@ public class NioEndpoint extends Abstrac } } else if (handshake == -1 ) { if (key != null) { - socket.getPoller().cancelledKey(key, SocketStatus.DISCONNECT); + socket.getPoller().cancelledKey(key); } if (running && !paused) { nioChannels.push(socket); @@ -1592,14 +1554,14 @@ public class NioEndpoint extends Abstrac } } catch (CancelledKeyException cx) { if (socket != null) { - socket.getPoller().cancelledKey(key, null); + socket.getPoller().cancelledKey(key); } } catch (OutOfMemoryError oom) { try { oomParachuteData = null; log.error("", oom); if (socket != null) { - socket.getPoller().cancelledKey(key,SocketStatus.ERROR); + socket.getPoller().cancelledKey(key); } releaseCaches(); } catch (Throwable oomt) { @@ -1615,7 +1577,7 @@ public class NioEndpoint extends Abstrac } catch (Throwable t) { log.error("", t); if (socket != null) { - socket.getPoller().cancelledKey(key,SocketStatus.ERROR); + socket.getPoller().cancelledKey(key); } } finally { socket = null; Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java Tue Nov 4 11:54:58 2014 @@ -84,7 +84,7 @@ public class SecureNio2Channel extends N } @Override public void failed(Throwable exc, SocketWrapper<Nio2Channel> attachment) { - endpoint.closeSocket(attachment, SocketStatus.ERROR); + endpoint.closeSocket(attachment); } }; handshakeWriteCompletionHandler = new CompletionHandler<Integer, SocketWrapper<Nio2Channel>>() { @@ -98,7 +98,7 @@ public class SecureNio2Channel extends N } @Override public void failed(Throwable exc, SocketWrapper<Nio2Channel> attachment) { - endpoint.closeSocket(attachment, SocketStatus.ERROR); + endpoint.closeSocket(attachment); } }; } Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapper.java Tue Nov 4 11:54:58 2014 @@ -31,7 +31,6 @@ public class SocketWrapper<E> { private long timeout = -1; private boolean error = false; private volatile int keepAliveLeft = 100; - private volatile boolean comet = false; private volatile boolean async = false; private boolean keptAlive = false; private volatile boolean upgraded = false; @@ -76,8 +75,6 @@ public class SocketWrapper<E> { return socket; } - public boolean isComet() { return comet; } - public void setComet(boolean comet) { this.comet = comet; } public boolean isAsync() { return async; } public void setAsync(boolean async) { this.async = async; } public boolean isUpgraded() { return upgraded; } @@ -155,7 +152,6 @@ public class SocketWrapper<E> { public void reset(E socket, long timeout) { async = false; blockingStatus = true; - comet = false; dispatches.clear(); error = false; keepAliveLeft = 100; Modified: tomcat/trunk/webapps/docs/aio.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/aio.xml?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/aio.xml (original) +++ tomcat/trunk/webapps/docs/aio.xml Tue Nov 4 11:54:58 2014 @@ -49,271 +49,6 @@ </section> - <section name="Comet support"> - - <p> - Comet support allows a servlet to process IO asynchronously, receiving - events when data is available for reading on the connection (rather than - always using a blocking read), and writing data back on connections - asynchronously (most likely responding to some event raised from some - other source). - </p> - - <subsection name="CometEvent"> - - <p> - Servlets which implement the <code>org.apache.catalina.comet.CometProcessor</code> - interface will have their event method invoked rather than the usual service - method, according to the event which occurred. The event object gives - access to the usual request and response objects, which may be used in the - usual way. The main difference is that those objects remain valid and fully - functional at any time between processing of the BEGIN event until processing - an END or ERROR event. - The following event types exist: - </p> - - <ul> - <li>EventType.BEGIN: will be called at the beginning - of the processing of the connection. It can be used to initialize any relevant - fields using the request and response objects. Between the end of the processing - of this event, and the beginning of the processing of the end or error events, - it is possible to use the response object to write data on the open connection. - Note that the response object and dependent OutputStream and Writer are still - not synchronized, so when they are accessed by multiple threads, - synchronization is mandatory. After processing the initial event, the request - is considered to be committed.</li> - <li>EventType.READ: This indicates that input data is available, and that one read can be made - without blocking. The available and ready methods of the InputStream or - Reader may be used to determine if there is a risk of blocking: the servlet - should read while data is reported available. When encountering a read error, - the servlet should report it by propagating the exception properly. Throwing - an exception will cause the error event to be invoked, and the connection - will be closed. - Alternately, it is also possible to catch any exception, perform clean up - on any data structure the servlet may be using, and using the close method - of the event. It is not allowed to attempt reading data from the request - object outside of the execution of this method.<br/> - On some platforms, like Windows, a client disconnect is indicated by a READ event. - Reading from the stream may result in -1, an IOException or an EOFException. - Make sure you properly handle all these three cases. - If you don't catch the IOException, Tomcat will instantly invoke your event chain with an ERROR as - it catches the error for you, and you will be notified of the error at that time. - </li> - <li>EventType.END: End may be called to end the processing of the request. Fields that have - been initialized in the begin method should be reset. After this event has - been processed, the request and response objects, as well as all their dependent - objects will be recycled and used to process other requests. End will also be - called when data is available and the end of file is reached on the request input - (this usually indicates the client has pipelined a request).</li> - <li>EventType.ERROR: Error will be called by the container in the case where an IO exception - or a similar unrecoverable error occurs on the connection. Fields that have - been initialized in the begin method should be reset. After this event has - been processed, the request and response objects, as well as all their dependent - objects will be recycled and used to process other requests.</li> - </ul> - - <p> - There are some event subtypes which allow finer processing of events (note: some of these - events require usage of the org.apache.catalina.valves.CometConnectionManagerValve valve): - </p> - - <ul> - <li>EventSubType.TIMEOUT: The connection timed out (sub type of ERROR); note that this ERROR - type is not fatal, and the connection will not be closed unless the servlet uses the close - method of the event. - </li> - <li>EventSubType.CLIENT_DISCONNECT: The client connection was closed (sub type of ERROR). - </li> - <li>EventSubType.IOEXCEPTION: An IO exception occurred, such as invalid content, for example, - an invalid chunk block (sub type of ERROR). - </li> - <li>EventSubType.WEBAPP_RELOAD: The web application is being reloaded (sub type of END). - </li> - <li>EventSubType.SESSION_END: The servlet ended the session (sub type of END). - </li> - </ul> - - <p> - As described above, the typical lifecycle of a Comet request will consist in a series of - events such as: BEGIN -> READ -> READ -> READ -> ERROR/TIMEOUT. At any time, the servlet - may end processing of the request by using the close method of the event object. - </p> - - </subsection> - - <subsection name="CometFilter"> - - <p> - Similar to regular filters, a filter chain is invoked when comet events are processed. - These filters should implement the CometFilter interface (which works in the same way as - the regular Filter interface), and should be declared and mapped in the deployment - descriptor in the same way as a regular filter. The filter chain when processing an event - will only include filters which match all the usual mapping rules, and also implement - the CometFiler interface. - </p> - - </subsection> - - <subsection name="Example code"> - - <p> - The following pseudo code servlet implements asynchronous chat functionality using the API - described above: - </p> - - <source><![CDATA[public class ChatServlet - extends HttpServlet implements CometProcessor { - - protected ArrayList<HttpServletResponse> connections = - new ArrayList<HttpServletResponse>(); - protected MessageSender messageSender = null; - - public void init() throws ServletException { - messageSender = new MessageSender(); - Thread messageSenderThread = - new Thread(messageSender, "MessageSender[" + getServletContext().getContextPath() + "]"); - messageSenderThread.setDaemon(true); - messageSenderThread.start(); - } - - public void destroy() { - connections.clear(); - messageSender.stop(); - messageSender = null; - } - - /** - * Process the given Comet event. - * - * @param event The Comet event that will be processed - * @throws IOException - * @throws ServletException - */ - public void event(CometEvent event) - throws IOException, ServletException { - HttpServletRequest request = event.getHttpServletRequest(); - HttpServletResponse response = event.getHttpServletResponse(); - if (event.getEventType() == CometEvent.EventType.BEGIN) { - log("Begin for session: " + request.getSession(true).getId()); - PrintWriter writer = response.getWriter(); - writer.println("<!DOCTYPE html>"); - writer.println("<head><title>JSP Chat</title></head><body>"); - writer.flush(); - synchronized(connections) { - connections.add(response); - } - } else if (event.getEventType() == CometEvent.EventType.ERROR) { - log("Error for session: " + request.getSession(true).getId()); - synchronized(connections) { - connections.remove(response); - } - event.close(); - } else if (event.getEventType() == CometEvent.EventType.END) { - log("End for session: " + request.getSession(true).getId()); - synchronized(connections) { - connections.remove(response); - } - PrintWriter writer = response.getWriter(); - writer.println("</body></html>"); - event.close(); - } else if (event.getEventType() == CometEvent.EventType.READ) { - InputStream is = request.getInputStream(); - byte[] buf = new byte[512]; - do { - int n = is.read(buf); //can throw an IOException - if (n > 0) { - log("Read " + n + " bytes: " + new String(buf, 0, n) - + " for session: " + request.getSession(true).getId()); - } else if (n < 0) { - error(event, request, response); - return; - } - } while (is.available() > 0); - } - } - - public class MessageSender implements Runnable { - - protected boolean running = true; - protected ArrayList<String> messages = new ArrayList<String>(); - - public MessageSender() { - } - - public void stop() { - running = false; - } - - /** - * Add message for sending. - */ - public void send(String user, String message) { - synchronized (messages) { - messages.add("[" + user + "]: " + message); - messages.notify(); - } - } - - public void run() { - - while (running) { - - if (messages.size() == 0) { - try { - synchronized (messages) { - messages.wait(); - } - } catch (InterruptedException e) { - // Ignore - } - } - - synchronized (connections) { - String[] pendingMessages = null; - synchronized (messages) { - pendingMessages = messages.toArray(new String[0]); - messages.clear(); - } - // Send any pending message on all the open connections - for (int i = 0; i < connections.size(); i++) { - try { - PrintWriter writer = connections.get(i).getWriter(); - for (int j = 0; j < pendingMessages.length; j++) { - writer.println(pendingMessages[j] + "<br>"); - } - writer.flush(); - } catch (IOException e) { - log("IOExeption sending message", e); - } - } - } - - } - - } - - } - -}]]></source> - - </subsection> - <subsection name="Comet timeouts"> - <p>If you are using the NIO connector, you can set individual timeouts for your different comet connections. - To set a timeout, simply set a request attribute like the following code shows:</p> - <source>CometEvent event.... event.setTimeout(30*1000);</source> - <p>or</p> - <source>event.getHttpServletRequest().setAttribute("org.apache.tomcat.comet.timeout", new Integer(30 * 1000));</source> - <p> - This sets the timeout to 30 seconds. - Important note: in order to set this timeout, it has to be done on the <code>BEGIN</code> event. - The default value is <code>soTimeout</code> - </p> - <p>If you are using the APR connector, all Comet connections will have the same timeout value. It is <code>soTimeout*50</code> - </p> - </subsection> - - </section> - <section name="Asynchronous writes"> <p> Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Tue Nov 4 11:54:58 2014 @@ -54,6 +54,9 @@ Make Java 8 the minimum required version to build and run Tomcat 9. (markt) </add> + <update> + Remove support for Comet. (markt) + </update> </subsection> </section> </body> Modified: tomcat/trunk/webapps/docs/config/http.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/http.xml?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/config/http.xml (original) +++ tomcat/trunk/webapps/docs/config/http.xml Tue Nov 4 11:54:58 2014 @@ -677,11 +677,6 @@ default value is <code>1000</code> milliseconds.</p> </attribute> - <attribute name="useComet" required="false"> - <p>(bool)Whether to allow comet servlets or not. Default value is - <code>true</code>.</p> - </attribute> - <attribute name="useSendfile" required="false"> <p>(bool)Use this attribute to enable or disable sendfile capability. The default value is <code>true</code>. Note that the use of sendfile @@ -812,11 +807,6 @@ The default value is <code>false</code>.</p> </attribute> - <attribute name="useComet" required="false"> - <p>(bool)Whether to allow comet servlets or not. Default value is - <code>true</code>.</p> - </attribute> - <attribute name="useSendfile" required="false"> <p>(bool)Use this attribute to enable or disable sendfile capability. The default value is <code>true</code>. Note that the use of sendfile @@ -964,11 +954,6 @@ this priority means.</p> </attribute> - <attribute name="useComet" required="false"> - <p>(bool)Whether to allow comet servlets or not. Default value is - <code>true</code>.</p> - </attribute> - <attribute name="useSendfile" required="false"> <p>(bool)Use this attribute to enable or disable sendfile capability. The default value is <code>true</code>. Note that the use of sendfile Modified: tomcat/trunk/webapps/examples/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/web.xml?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/webapps/examples/WEB-INF/web.xml (original) +++ tomcat/trunk/webapps/examples/WEB-INF/web.xml Tue Nov 4 11:54:58 2014 @@ -122,10 +122,6 @@ <servlet-class>ServletToJsp</servlet-class> </servlet> <servlet> - <servlet-name>ChatServlet</servlet-name> - <servlet-class>chat.ChatServlet</servlet-class> - </servlet> - <servlet> <servlet-name>CompressionFilterTestServlet</servlet-name> <servlet-class>compressionFilters.CompressionFilterTestServlet</servlet-class> </servlet> @@ -155,10 +151,6 @@ </servlet> <servlet-mapping> - <servlet-name>ChatServlet</servlet-name> - <url-pattern>/servlets/chat/chat</url-pattern> - </servlet-mapping> - <servlet-mapping> <servlet-name>CompressionFilterTestServlet</servlet-name> <url-pattern>/CompressionTest</url-pattern> </servlet-mapping> Modified: tomcat/trunk/webapps/examples/servlets/index.html URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/servlets/index.html?rev=1636547&r1=1636546&r2=1636547&view=diff ============================================================================== --- tomcat/trunk/webapps/examples/servlets/index.html (original) +++ tomcat/trunk/webapps/examples/servlets/index.html Tue Nov 4 11:54:58 2014 @@ -149,20 +149,6 @@ for clarity.</p> </tr> <tr> - <th colspan="3">Comet processing example:<br /> - <span style="font-weight: normal;">See the <strong>"Advanced IO"</strong> chapter in the User Guide for - details. This example only works with the HTTP NIO or HTTP APR/native - connectors as these are the only connectors that support Comet.</span></th> -</tr> -<tr> - <td>Comet Chat</td> - <td style="width: 30%;"> - <a href="chat/"><img SRC="images/execute.gif" alt=""> Execute</a> - </td> - <td style="width: 30%;"></td> -</tr> - -<tr> <th colspan="3">Servlet 3.1 Non-blocking IO examples</th> </tr> <tr> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org