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/10/10 12:47:58 UTC

[tomcat] 02/03: Fix instance where pipelined data may be missed after an async request

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

commit 0726d82ac2627a505f2be32712f1816b51dad4f4
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Oct 9 21:52:31 2019 +0100

    Fix instance where pipelined data may be missed after an async request
---
 java/org/apache/coyote/AbstractProcessorLight.java | 27 +++++++++++++++-------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/coyote/AbstractProcessorLight.java b/java/org/apache/coyote/AbstractProcessorLight.java
index 049797d..b26b41f 100644
--- a/java/org/apache/coyote/AbstractProcessorLight.java
+++ b/java/org/apache/coyote/AbstractProcessorLight.java
@@ -50,18 +50,14 @@ public abstract class AbstractProcessorLight implements Processor {
                     getLog().debug("Processing dispatch type: [" + nextDispatch + "]");
                 }
                 state = dispatch(nextDispatch.getSocketStatus());
+                if (!dispatches.hasNext()) {
+                    state = checkForPipelinedData(state, socketWrapper);
+                }
             } else if (status == SocketEvent.DISCONNECT) {
                 // Do nothing here, just wait for it to get recycled
             } else if (isAsync() || isUpgrade() || state == SocketState.ASYNC_END) {
                 state = dispatch(status);
-                if (state == SocketState.OPEN) {
-                    // There may be pipe-lined data to read. If the data isn't
-                    // processed now, execution will exit this loop and call
-                    // release() which will recycle the processor (and input
-                    // buffer) deleting any pipe-lined data. To avoid this,
-                    // process it now.
-                    state = service(socketWrapper);
-                }
+                state = checkForPipelinedData(state, socketWrapper);
             } else if (status == SocketEvent.OPEN_WRITE) {
                 // Extra write event likely after async, ignore
                 state = SocketState.LONG;
@@ -101,6 +97,21 @@ public abstract class AbstractProcessorLight implements Processor {
     }
 
 
+    private SocketState checkForPipelinedData(SocketState inState, SocketWrapperBase<?> socketWrapper)
+            throws IOException {
+        if (inState == SocketState.OPEN) {
+            // There may be pipe-lined data to read. If the data isn't
+            // processed now, execution will exit this loop and call
+            // release() which will recycle the processor (and input
+            // buffer) deleting any pipe-lined data. To avoid this,
+            // process it now.
+            return service(socketWrapper);
+        } else {
+            return inState;
+        }
+    }
+
+
     public void addDispatch(DispatchType dispatchType) {
         synchronized (dispatches) {
             dispatches.add(dispatchType);


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