This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push: new 474701d1c4 Align NioChannel and SecureNioChannel 474701d1c4 is described below commit 474701d1c4872bcd9e530444d61677863d8bc09d 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 423e024c74..ff466e8bdd 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -135,6 +135,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