This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new 79009baf0a Align NioChannel and SecureNioChannel 79009baf0a is described below commit 79009baf0af9e0f2b02753a352e31e5bb3f85396 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Apr 17 10:42:29 2024 +0100 Align NioChannel and SecureNioChannel Skipping empty writes can provide a performance improvement for some frameworks - typically those that call flush() more than they need to --- java/org/apache/tomcat/util/net/NioChannel.java | 4 ++++ webapps/docs/changelog.xml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/java/org/apache/tomcat/util/net/NioChannel.java b/java/org/apache/tomcat/util/net/NioChannel.java index 6ddf5637f0..c350577a4b 100644 --- a/java/org/apache/tomcat/util/net/NioChannel.java +++ b/java/org/apache/tomcat/util/net/NioChannel.java @@ -115,6 +115,10 @@ public class NioChannel implements ByteChannel, ScatteringByteChannel, Gathering @Override public int write(ByteBuffer src) throws IOException { checkInterruptStatus(); + if (!src.hasRemaining()) { + // Nothing left to write + return 0; + } return sc.write(src); } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 0cf84d9b86..8ef77e52aa 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -130,6 +130,10 @@ <fix> Add OpenSSL FFM classes to <code>tomcat-embed-core.jar</code>. (remm) </fix> + <fix> + Align non-secure and secure writes with NIO and skip the write attempt + when there are no bytes to be written. (markt) + </fix> </changelog> </subsection> <subsection name="Other"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org