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 2ed6d18ebf Performance optimisation for AJP. Don't swallow body on 
error conditions
2ed6d18ebf is described below

commit 2ed6d18ebfe4b085ef050dd0a0f4f20aff3bc48d
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Aug 24 14:42:59 2026 +0100

    Performance optimisation for AJP. Don't swallow body on error conditions
---
 java/org/apache/coyote/ajp/AjpProcessor.java | 13 +++++++------
 webapps/docs/changelog.xml                   |  4 ++++
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java 
b/java/org/apache/coyote/ajp/AjpProcessor.java
index 72e8cc2c77..6b120abc0b 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -1077,15 +1077,16 @@ public class AjpProcessor extends AbstractProcessor {
             return;
         }
 
-        // Swallow the unread body packet if present
-        if (waitingForBodyMessage || first && request.getContentLengthLong() > 
0) {
-            refillReadBuffer(true);
-        }
-
-        // Add the end message
         if (getErrorState().isError()) {
+            // Write the end and close message
             socketWrapper.write(true, endAndCloseMessageArray, 0, 
endAndCloseMessageArray.length);
         } else {
+            // Swallow the unread body packet if present
+            if (waitingForBodyMessage || first && 
request.getContentLengthLong() > 0) {
+                refillReadBuffer(true);
+            }
+
+            // Write the end message
             socketWrapper.write(true, endMessageArray, 0, 
endMessageArray.length);
         }
         socketWrapper.flush(true);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index ba7cc3130c..9e75a239d3 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -223,6 +223,10 @@
         Cleaner handling of AJP response headers which overflow the maximum
         message size. (remm)
       </fix>
+      <fix>
+        Small per performance optimisation. Don't waste cycles swallowing an 
AJP
+        response body when the connection is going to be closed. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to