[ 
https://issues.apache.org/jira/browse/SSHD-1256?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17608976#comment-17608976
 ] 

Thomas Wolf commented on SSHD-1256:
-----------------------------------

Possibly also related:
 * [JDK-8214430|https://bugs.openjdk.org/browse/JDK-8214430]
 * [Java 11 Release 
Notes|https://www.oracle.com/java/technologies/javase/11-relnote-issues.html#JDK-8198562]

That gives rise to another theory, which would be consistent with the test 
failing only with Apache MINA (and IIRC I also have not seen it failing on Java 
8):

Apache MINA does the follow when unbinding the {{{}ServerSocketChannel{}}}:
 # Application thread: Put a close future for the channel on a cancel queue
 # Application thread: Wake up the current {{select()}}
 # Application thread: Wait until the future is completed
 # I/O thread: {{select()}} is interrupted
 # I/O thread: Process the cancel queue: poll the close future, cancel the 
channel's {{SelectorKey}} and close the channel; fulfill the close future
 # I/O thread: Perform the next {{select()}}

So step 5 wakes up the application thread blocked in 3 which then returns and 
says the port forwarding was cancelled, but the socket may be given up only in 
6 on Java >=11. Hence there _is_ a race condition, and if the second {{bind()}} 
arrives before step 6 has indeed given up the socket, then the test fails. 
Looks like Apache MINA should ensure that between processing the cancel queue 
and processing the registration queue there was an intervening {{{}select(){}}}?

> PortForwardingTest.testRemoteForwardingSecondTimeInSameSession sometimes 
> fails in Github CI
> -------------------------------------------------------------------------------------------
>
>                 Key: SSHD-1256
>                 URL: https://issues.apache.org/jira/browse/SSHD-1256
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 2.9.0
>            Reporter: Thomas Wolf
>            Priority: Major
>
> Cannot reproduce locally. A timing issue?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org

Reply via email to