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
commit c3e3deaccca128a6c57ec801128f65be8e291dc4 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Mar 25 16:19:49 2021 +0000 Fix intermittent CI failure If the complete/dispatch is on a new thread there is a race condition between the new thread and the container thread. The COMPLETE_PENDIND and DISPATCH_PENDING states were created to handle this scenario so use them. --- java/org/apache/coyote/AsyncStateMachine.java | 34 +++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/java/org/apache/coyote/AsyncStateMachine.java b/java/org/apache/coyote/AsyncStateMachine.java index 2f9a28d..0826a2c 100644 --- a/java/org/apache/coyote/AsyncStateMachine.java +++ b/java/org/apache/coyote/AsyncStateMachine.java @@ -91,21 +91,23 @@ import org.apache.tomcat.util.security.PrivilegedSetTccl; * | / | \ | * | OT-complete() / | \ OT-dispatch() | * | COMPLETE_PENDING«------«------/ | \-------»---------»DISPATCH_PENDING | - * | | | | | - * | post()| timeout() post()| post() post()| timeout() | - * | | |--| | |--| | |--| | - * | \|/ \|/ | complete() \|/\|/ | dispatch() \|/ \|/ | | + * | | /|\ | /|\ | | + * | | | | | |post() | + * | | |complete() | dispatch()| | | + * | | | | | | | + * | | |---------«-------«-- | --«---READ_WRITE--»----| | | + * | | | / /|\ | | + * | | | post()/ / | | + * | | | / / | | + * | | | / / | | + * | | | / / | | + * | post()| timeout() post()| / /asyncOperation() | timeout() | + * | | |--| | | / | |--| | + * | \|/ \|/ | complete() \|/ \|// dispatch() \|/ \|/ | | * |--«-----COMPLETING«--------«----------STARTED--------»---------»DISPATCHING----| - * /|\ /|\ /|\ | /|\ \ /|\ /|\ /|\ - * | | | | \ \asyncOperation() | | | - * | | | timeout()| \ \ | | | - * | | | | \ \ | | | - * | | | | \ \ | | | - * | | | | \ \ | | | - * | | | | \ \ | | | - * | | | | post()\ \ dispatch()| | | - * | | | complete() | \ \|/ | | | - * | | |---«------------«-- | --«---READ_WRITE----»----| | | + * /|\ /|\ | /|\ | /|\ /|\ + * | | | |--| | | + * | | timeout()| post() | | * | | | | | * | | complete() \|/ dispatch() | | * | |------------«-------TIMING_OUT--------»----------------| | @@ -359,8 +361,10 @@ public class AsyncStateMachine { } + public synchronized boolean asyncDispatch() { - if (!ContainerThreadMarker.isContainerThread() && state == AsyncState.STARTING) { + if (!ContainerThreadMarker.isContainerThread() && state == AsyncState.STARTING || + state == AsyncState.READ_WRITE_OP) { updateState(AsyncState.DISPATCH_PENDING); return false; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org