This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 7b38c990e9 Ensure non-blocking write buffer is empty before sending
AJP control messages
7b38c990e9 is described below
commit 7b38c990e9f9622eaca05d671979d15c597baec0
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 c5eaba6c84..571dcda417 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -630,6 +630,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;
@@ -1058,11 +1060,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 49809b3ad6..524d6896ce 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]