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 8105776  Revert to the previous revision
8105776 is described below

commit 8105776b9c4d484ea8fda8f8be8eb0f82d6c9a1f
Author: remm <r...@apache.org>
AuthorDate: Wed Mar 27 18:37:09 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 27891d5..c38dc70 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -731,7 +731,22 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint<Nio2Channel> {
                 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;
             }
         }
 
@@ -1233,6 +1248,7 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint<Nio2Channel> {
             // 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
@@ -1244,7 +1260,7 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint<Nio2Channel> {
                         // Remaining data must be buffered
                         nonBlockingWriteBuffer.add(buf, off, len);
                     }
-                    flushNonBlocking(true);
+                    flushNonBlockingInternal(true);
                 } else {
                     nonBlockingWriteBuffer.add(buf, off, len);
                 }
@@ -1283,6 +1299,7 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint<Nio2Channel> {
             // 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
@@ -1292,7 +1309,7 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint<Nio2Channel> {
                         // Remaining data must be buffered
                         nonBlockingWriteBuffer.add(from);
                     }
-                    flushNonBlocking(true);
+                    flushNonBlockingInternal(true);
                 } else {
                     nonBlockingWriteBuffer.add(from);
                 }
@@ -1357,11 +1374,11 @@ public class Nio2Endpoint extends 
AbstractJsseEndpoint<Nio2Channel> {
 
         @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

Reply via email to