This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push:
new d8854d9 Further align complete()/dispatch() if called during async I/O
d8854d9 is described below
commit d8854d9dec2ae2130cf30c509cfc79cbc0ec002d
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Oct 11 11:30:00 2019 +0100
Further align complete()/dispatch() if called during async I/O
---
java/org/apache/coyote/AsyncStateMachine.java | 37 +++++++++++++++------------
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/java/org/apache/coyote/AsyncStateMachine.java
b/java/org/apache/coyote/AsyncStateMachine.java
index a1486aa..d4df0ff 100644
--- a/java/org/apache/coyote/AsyncStateMachine.java
+++ b/java/org/apache/coyote/AsyncStateMachine.java
@@ -278,22 +278,28 @@ public class AsyncStateMachine<S> {
private synchronized boolean doComplete() {
- boolean doComplete = false;
- if (state == AsyncState.STARTING) {
+ boolean triggerDispatch = false;
+ if (state == AsyncState.STARTING || state == AsyncState.TIMING_OUT ||
+ state == AsyncState.ERROR) {
+ // Processing is on a container thread so no need to transfer
+ // processing to a new container thread
state = AsyncState.MUST_COMPLETE;
} else if (state == AsyncState.STARTED || state ==
AsyncState.COMPLETE_PENDING) {
state = AsyncState.COMPLETING;
- doComplete = true;
- } else if (state == AsyncState.TIMING_OUT ||
- state == AsyncState.ERROR) {
- state = AsyncState.MUST_COMPLETE;
+ // A dispatch to a container thread is always required.
+ // If on a non-container thread, need to get back onto a container
+ // thread to complete the processing.
+ // If on a container thread the current request/response are not
the
+ // request/response associated with the AsyncContext so need a new
+ // container thread to process the different request/response.
+ triggerDispatch = true;
} else {
throw new IllegalStateException(
sm.getString("asyncStateMachine.invalidAsyncState",
"asyncComplete()", state));
}
- return doComplete;
+ return triggerDispatch;
}
@@ -326,28 +332,27 @@ public class AsyncStateMachine<S> {
private synchronized boolean doDispatch() {
- boolean doDispatch = false;
- if (state == AsyncState.STARTING ||
- state == AsyncState.TIMING_OUT ||
+ boolean triggerDispatch = false;
+ if (state == AsyncState.STARTING || state == AsyncState.TIMING_OUT ||
state == AsyncState.ERROR) {
- // In these three cases processing is on a container thread so no
- // need to transfer processing to a new container thread
+ // Processing is on a container thread so no need to transfer
+ // processing to a new container thread
state = AsyncState.MUST_DISPATCH;
} else if (state == AsyncState.STARTED || state ==
AsyncState.DISPATCH_PENDING) {
- // A dispatch is always required.
+ state = AsyncState.DISPATCHING;
+ // A dispatch to a container thread is always required.
// If on a non-container thread, need to get back onto a container
// thread to complete the processing.
// If on a container thread the current request/response are not
the
// request/response associated with the AsyncContext so need a new
// container thread to process the different request/response.
- state = AsyncState.DISPATCHING;
- doDispatch = true;
+ triggerDispatch = true;
} else {
throw new IllegalStateException(
sm.getString("asyncStateMachine.invalidAsyncState",
"asyncDispatch()", state));
}
- return doDispatch;
+ return triggerDispatch;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]