This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new 7e0947e Re-work fix for complete()/dispatch() when in READ_WRITE state
7e0947e is described below
commit 7e0947ede53c5593156f03dd90d7ac9e560de56e
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Mar 25 17:52:24 2021 +0000
Re-work fix for complete()/dispatch() when in READ_WRITE state
Previous fix only addressed dispatch. Mirror changes to complete().
The *_PENDING states are only required if the complete()/dispatch() is
performed on a non-container thread. If on a container thread the race
condition cannot occur.
---
java/org/apache/coyote/AsyncStateMachine.java | 38 +++++++++++++++------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/java/org/apache/coyote/AsyncStateMachine.java
b/java/org/apache/coyote/AsyncStateMachine.java
index 0826a2c..c45c6b2 100644
--- a/java/org/apache/coyote/AsyncStateMachine.java
+++ b/java/org/apache/coyote/AsyncStateMachine.java
@@ -91,19 +91,23 @@ import org.apache.tomcat.util.security.PrivilegedSetTccl;
* | / | \
|
* | OT-complete() / | \ OT-dispatch()
|
* | COMPLETE_PENDING«------«------/ |
\-------»---------»DISPATCH_PENDING |
- * | | /|\ | /|\ |
|
- * | | | | |
|post() |
- * | | |complete() | dispatch()| |
|
- * | | | | | |
|
- * | | |---------«-------«-- | --«---READ_WRITE--»----| |
|
- * | | | / /|\ |
|
- * | | | post()/ / |
|
- * | | | / / |
|
- * | | | / / |
|
- * | | | / / |
|
- * | post()| timeout() post()| / /asyncOperation() |
timeout() |
- * | | |--| | | / |
|--| |
- * | \|/ \|/ | complete() \|/ \|// dispatch() \|/
\|/ | |
+ * | | /|\ | /|\ |
|
+ * | | | | |
|post() |
+ * | | |OT-complete() | OT-dispatch()| |
|
+ * | | |---------«-------«---|---«--\ | |
|
+ * | | | \ | |
|
+ * | | /-------«-------«-- | --«---READ_WRITE--»----| |
|
+ * | | / ST-complete() | / /|\ \ |
|
+ * | | / | post()/ / \ |
|
+ * | | / | / / \ |
|
+ * | | / | / / \ |
|
+ * | | / | / / \ |
|
+ * | | / | | / \ |
|
+ * | | / | | / ST-dispatch()\ |
|
+ * | | | | | | \ |
|
+ * | post()| | timeout() post()| | |asyncOperation() \ |
timeout() |
+ * | | | |--| | | | | |
|--| |
+ * | \|/\|/\|/ | complete() \|/ \|/| dispatch() \|/\|/
\|/ | |
*
|--«-----COMPLETING«--------«----------STARTED--------»---------»DISPATCHING----|
* /|\ /|\ | /|\ | /|\
/|\
* | | | |--| |
|
@@ -301,7 +305,8 @@ public class AsyncStateMachine {
public synchronized boolean asyncComplete() {
- if (!ContainerThreadMarker.isContainerThread() && state ==
AsyncState.STARTING) {
+ if (!ContainerThreadMarker.isContainerThread() &&
+ (state == AsyncState.STARTING || state ==
AsyncState.READ_WRITE_OP)) {
updateState(AsyncState.COMPLETE_PENDING);
return false;
}
@@ -361,10 +366,9 @@ public class AsyncStateMachine {
}
-
public synchronized boolean asyncDispatch() {
- if (!ContainerThreadMarker.isContainerThread() && state ==
AsyncState.STARTING ||
- state == AsyncState.READ_WRITE_OP) {
+ if (!ContainerThreadMarker.isContainerThread() &&
+ (state == AsyncState.STARTING || state ==
AsyncState.READ_WRITE_OP)) {
updateState(AsyncState.DISPATCH_PENDING);
return false;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]