This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push: new c24521d Harmonize HTTP/1.1 NIO2 keepalive code c24521d is described below commit c24521d7d9e3801090ce7d718a377b0c518d092a Author: remm <r...@apache.org> AuthorDate: Mon Mar 11 10:30:56 2019 +0100 Harmonize HTTP/1.1 NIO2 keepalive code Following the fixes and refactorings, only sendfile was using the classic long poll read (awaitBytes). As the other path is working fine for other keepalive scenarios and this is only used for large files, keeping it is not required. --- java/org/apache/tomcat/util/net/Nio2Endpoint.java | 34 +---------------------- webapps/docs/changelog.xml | 3 ++ 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java b/java/org/apache/tomcat/util/net/Nio2Endpoint.java index 7bd7191..edfd10e 100644 --- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java +++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java @@ -27,7 +27,6 @@ import java.nio.channels.AsynchronousChannelGroup; import java.nio.channels.AsynchronousCloseException; import java.nio.channels.AsynchronousServerSocketChannel; import java.nio.channels.AsynchronousSocketChannel; -import java.nio.channels.ClosedChannelException; import java.nio.channels.CompletionHandler; import java.nio.channels.FileChannel; import java.nio.channels.InterruptedByTimeoutException; @@ -486,25 +485,6 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS private boolean writeNotify = false; private volatile boolean closed = false; - private CompletionHandler<Integer, SocketWrapperBase<Nio2Channel>> awaitBytesHandler - = new CompletionHandler<Integer, SocketWrapperBase<Nio2Channel>>() { - - @Override - public void completed(Integer nBytes, SocketWrapperBase<Nio2Channel> attachment) { - if (nBytes.intValue() < 0) { - failed(new ClosedChannelException(), attachment); - return; - } - readNotify = true; - getEndpoint().processSocket(attachment, SocketEvent.OPEN_READ, Nio2Endpoint.isInline()); - } - - @Override - public void failed(Throwable exc, SocketWrapperBase<Nio2Channel> attachment) { - getEndpoint().processSocket(attachment, SocketEvent.DISCONNECT, true); - } - }; - private CompletionHandler<Integer, SendfileData> sendfileHandler = new CompletionHandler<Integer, SendfileData>() { @@ -540,7 +520,7 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS break; } case OPEN: { - awaitBytes(); + registerReadInterest(); break; } } @@ -1538,18 +1518,6 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS } - public void awaitBytes() { - // NO-OP is there is already a read in progress. - if (readPending.tryAcquire()) { - getSocket().getBufHandler().configureReadBufferForWrite(); - Nio2Endpoint.startInline(); - getSocket().read(getSocket().getBufHandler().getReadBuffer(), - toNio2Timeout(getReadTimeout()), TimeUnit.MILLISECONDS, this, awaitBytesHandler); - Nio2Endpoint.endInline(); - } - } - - @Override public SendfileDataBase createSendfileData(String filename, long pos, long length) { return new SendfileData(filename, pos, length); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 3dd9625..43b6cfd 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -150,6 +150,9 @@ Avoid some overflow cases with OpenSSL to improve efficiency, as the OpenSSL engine has an internal buffer. (remm) </fix> + <fix> + Harmonize HTTP/1.1 NIO2 keepalive code. (remm) + </fix> </changelog> </subsection> <subsection name="WebSocket"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org