This is an automated email from the ASF dual-hosted git repository.
markt-asf 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 b7593a4ea2 Ensure non-blocking write buffer is empty before sending
AJP control messages
b7593a4ea2 is described below
commit b7593a4ea2ea6b5fb32386ed80ffc295b25395cb
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 7c3b09ffdb..84550be2da 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -623,6 +623,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;
@@ -1053,11 +1055,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 bf891921cf..6753cf1f64 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -241,6 +241,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]