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 4ee72e6 Revert to the previous revision 4ee72e6 is described below commit 4ee72e6512e7442de9c9fdfd3e17c207e42bec37 Author: remm <r...@apache.org> AuthorDate: Wed Mar 27 17:50:10 2019 +0100 Revert to the previous revision This was equivalent but slightly less efficient. Also cleanup the flushNonBlocking IOE check. --- java/org/apache/tomcat/util/net/Nio2Endpoint.java | 29 ++++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java b/java/org/apache/tomcat/util/net/Nio2Endpoint.java index 3397e18..b27ca4e 100644 --- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java +++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java @@ -744,7 +744,22 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS if (writeNotify) { return true; } - return super.isReadyForWrite(); + + if (!writePending.tryAcquire()) { + writeInterest = true; + return false; + } + + if (socketBufferHandler.isWriteBufferEmpty() && nonBlockingWriteBuffer.isEmpty()) { + writePending.release(); + return true; + } + + boolean isReady = !flushNonBlockingInternal(true); + if (!isReady) { + writeInterest = true; + } + return isReady; } } @@ -1246,6 +1261,7 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS // indicate the end of a write // Uses: if (writePending.tryAcquire(socketWrapper.getTimeout(), TimeUnit.MILLISECONDS)) synchronized (writeCompletionHandler) { + checkError(); if (writeNotify || writePending.tryAcquire()) { // No pending completion handler, so writing to the main buffer // is possible @@ -1257,7 +1273,7 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS // Remaining data must be buffered nonBlockingWriteBuffer.add(buf, off, len); } - flushNonBlocking(true); + flushNonBlockingInternal(true); } else { nonBlockingWriteBuffer.add(buf, off, len); } @@ -1296,6 +1312,7 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS // indicate the end of a write // Uses: if (writePending.tryAcquire(socketWrapper.getTimeout(), TimeUnit.MILLISECONDS)) synchronized (writeCompletionHandler) { + checkError(); if (writeNotify || writePending.tryAcquire()) { // No pending completion handler, so writing to the main buffer // is possible @@ -1305,7 +1322,7 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS // Remaining data must be buffered nonBlockingWriteBuffer.add(from); } - flushNonBlocking(true); + flushNonBlockingInternal(true); } else { nonBlockingWriteBuffer.add(from); } @@ -1370,11 +1387,11 @@ public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousS @Override protected boolean flushNonBlocking() throws IOException { - return flushNonBlocking(false); + checkError(); + return flushNonBlockingInternal(false); } - private boolean flushNonBlocking(boolean hasPermit) throws IOException { - checkError(); + private boolean flushNonBlockingInternal(boolean hasPermit) { synchronized (writeCompletionHandler) { if (writeNotify || hasPermit || writePending.tryAcquire()) { // The code that was notified is now writing its data --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org