This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 6f6d55296f Refactor in preparation for fixing BZ 66077 6f6d55296f is described below commit 6f6d55296f6532d46dfd886bd9eca1f79beb62dd Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri May 20 07:51:07 2022 +0100 Refactor in preparation for fixing BZ 66077 --- java/org/apache/tomcat/util/net/AprEndpoint.java | 23 ++++++++++++++++++++++ java/org/apache/tomcat/util/net/NioEndpoint.java | 23 ++++++++++++++++++++++ .../apache/tomcat/util/net/SocketWrapperBase.java | 21 +------------------- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java index 1b5f170064..c02e90fc09 100644 --- a/java/org/apache/tomcat/util/net/AprEndpoint.java +++ b/java/org/apache/tomcat/util/net/AprEndpoint.java @@ -2391,6 +2391,29 @@ public class AprEndpoint extends AbstractEndpoint<Long,Long> implements SNICallB } + @Override + protected boolean flushNonBlocking() throws IOException { + boolean dataLeft = !socketBufferHandler.isWriteBufferEmpty(); + + // Write to the socket, if there is anything to write + if (dataLeft) { + doWrite(false); + dataLeft = !socketBufferHandler.isWriteBufferEmpty(); + } + + if (!dataLeft && !nonBlockingWriteBuffer.isEmpty()) { + dataLeft = nonBlockingWriteBuffer.write(this, false); + + if (!dataLeft && !socketBufferHandler.isWriteBufferEmpty()) { + doWrite(false); + dataLeft = !socketBufferHandler.isWriteBufferEmpty(); + } + } + + return dataLeft; + } + + @Override protected void doWrite(boolean block, ByteBuffer from) throws IOException { Lock readLock = getBlockingStatusReadLock(); diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 3c7c8e68a0..78f4d3ca53 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -1343,6 +1343,29 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> } + @Override + protected boolean flushNonBlocking() throws IOException { + boolean dataLeft = !socketBufferHandler.isWriteBufferEmpty(); + + // Write to the socket, if there is anything to write + if (dataLeft) { + doWrite(false); + dataLeft = !socketBufferHandler.isWriteBufferEmpty(); + } + + if (!dataLeft && !nonBlockingWriteBuffer.isEmpty()) { + dataLeft = nonBlockingWriteBuffer.write(this, false); + + if (!dataLeft && !socketBufferHandler.isWriteBufferEmpty()) { + doWrite(false); + dataLeft = !socketBufferHandler.isWriteBufferEmpty(); + } + } + + return dataLeft; + } + + @Override protected void doWrite(boolean block, ByteBuffer buffer) throws IOException { int n = 0; diff --git a/java/org/apache/tomcat/util/net/SocketWrapperBase.java b/java/org/apache/tomcat/util/net/SocketWrapperBase.java index 3c1da33be4..67a6d0f08d 100644 --- a/java/org/apache/tomcat/util/net/SocketWrapperBase.java +++ b/java/org/apache/tomcat/util/net/SocketWrapperBase.java @@ -736,26 +736,7 @@ public abstract class SocketWrapperBase<E> { } - protected boolean flushNonBlocking() throws IOException { - boolean dataLeft = !socketBufferHandler.isWriteBufferEmpty(); - - // Write to the socket, if there is anything to write - if (dataLeft) { - doWrite(false); - dataLeft = !socketBufferHandler.isWriteBufferEmpty(); - } - - if (!dataLeft && !nonBlockingWriteBuffer.isEmpty()) { - dataLeft = nonBlockingWriteBuffer.write(this, false); - - if (!dataLeft && !socketBufferHandler.isWriteBufferEmpty()) { - doWrite(false); - dataLeft = !socketBufferHandler.isWriteBufferEmpty(); - } - } - - return dataLeft; - } + protected abstract boolean flushNonBlocking() throws IOException; /** --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org