This is an automated email from the ASF dual-hosted git repository.
markt-asf 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 b4c09942b3 Ensure non-blocking write buffer is empty before sending
AJP control messages
b4c09942b3 is described below
commit b4c09942b31bdba4b0124a02f89d5bf21deba435
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Nov 23 16:21:46 2026 +0000
Ensure non-blocking write buffer is empty before sending AJP control
messages
The get body chunk and flush messages were written using blocking writes
ahead of any response data still waiting in the non-blocking write buffer.
This could place them part way through a response body message and break
the AJP framing.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
java/org/apache/coyote/ajp/AjpProcessor.java | 6 +++++-
webapps/docs/changelog.xml | 5 +++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java
b/java/org/apache/coyote/ajp/AjpProcessor.java
index ba5f56e0cd..61d6f64d72 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -625,6 +625,8 @@ public class AjpProcessor extends AbstractProcessor {
// Request more data immediately
if (!waitingForBodyMessage) {
+ // Make sure the non-blocking write buffer is empty before sending
the get body chunk message.
+ socketWrapper.flush(true);
socketWrapper.write(true, getBodyMessageArray, 0,
getBodyMessageArray.length);
socketWrapper.flush(true);
waitingForBodyMessage = true;
@@ -1035,11 +1037,13 @@ public class AjpProcessor extends AbstractProcessor {
// Calling code should ensure that there is no data in the buffers for
// non-blocking writes.
if (!responseFinished && getErrorState().isIoAllowed()) {
+ // Make sure the non-blocking write buffer is empty before sending
the flush message.
+ socketWrapper.flush(true);
if (protocol.getAjpFlush()) {
// Send the flush message
socketWrapper.write(true, flushMessageArray, 0,
flushMessageArray.length);
+ socketWrapper.flush(true);
}
- socketWrapper.flush(true);
}
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 5bffc73185..7193483ac7 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -379,6 +379,11 @@
write timeouts while waiting for the client to send the HTTP/2
connection preface. (markt)
</fix>
+ <fix>
+ Ensure that the non-blocking write buffer is empty before sending an
AJP
+ get body chunk message or flush message so that the messages cannot be
+ written part way through a response body message. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]