This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 140e1fb0e9 Ensure non-blocking write buffer is empty before sending
AJP control messages
140e1fb0e9 is described below
commit 140e1fb0e983d5de4de3bb3013bbbc50d706e9f3
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 6c3d7fbb0c..a0855c7e7f 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;
@@ -1037,11 +1039,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 46fe4f43a2..f904346196 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]