This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new 8d2b491 Harmonize HTTP/1.1 NIO2 keepalive code 8d2b491 is described below commit 8d2b4915893f695d3a079edaa7b571558fe29f87 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 3a63503..fd19475 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; @@ -466,25 +465,6 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel> { 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>() { @@ -520,7 +500,7 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel> { break; } case OPEN: { - awaitBytes(); + registerReadInterest(); break; } } @@ -1506,18 +1486,6 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel> { } - 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 39df098..e333bc1 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -187,6 +187,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