You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/11/08 19:57:45 UTC

[tomcat] branch master updated: Fix logic that meant AJP was not always non-blocking between requests

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new ffb553c  Fix logic that meant AJP was not always non-blocking between requests
ffb553c is described below

commit ffb553c4c4315219762ed215965b73ee4f4d19c0
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Nov 8 19:57:00 2019 +0000

    Fix logic that meant AJP was not always non-blocking between requests
---
 java/org/apache/coyote/ajp/AjpProcessor.java | 8 +++++---
 webapps/docs/changelog.xml                   | 6 ++++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java b/java/org/apache/coyote/ajp/AjpProcessor.java
index a56fb7a..280a340 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -313,15 +313,18 @@ public class AjpProcessor extends AbstractProcessor {
         this.socketWrapper = socket;
 
         boolean cping = false;
-        boolean keptAlive = false;
+        // Expected to block on the first read as there should be at least one
+        // AJP message to read.
+        boolean firstRead = true;
 
         while (!getErrorState().isError() && !protocol.isPaused()) {
             // Parsing the request header
             try {
                 // Get first message of the request
-                if (!readMessage(requestHeaderMessage, !keptAlive)) {
+                if (!readMessage(requestHeaderMessage, firstRead)) {
                     break;
                 }
+                firstRead = false;
 
                 // Processing the request so make sure the connection rather
                 // than keep-alive timeout is used
@@ -353,7 +356,6 @@ public class AjpProcessor extends AbstractProcessor {
                     setErrorState(ErrorState.CLOSE_CONNECTION_NOW, null);
                     break;
                 }
-                keptAlive = true;
                 request.setStartTime(System.currentTimeMillis());
             } catch (IOException e) {
                 setErrorState(ErrorState.CLOSE_CONNECTION_NOW, e);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index fcc8dd5..c910d17 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -126,6 +126,12 @@
       <fix>
         Improve cleanup after errors when setting socket options. (remm)
       </fix>
+      <fix>
+        Do not perform a blocking read after a <code>CPING</code> message is
+        received by the AJP connector because, if the JK Connector is configured
+        with <code>ping_mode=&quot;I&quot;</code>, the <code>CPING</code>
+        message will not always be followed by the start of a request. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org