Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SSHClient to interrupt KeepAlive Thread when disconnecting #752

Merged
merged 2 commits into from
Dec 22, 2021

Conversation

exceptionfactory
Copy link
Contributor

The current KeepAlive.setKeepAliveInterval() method starts the Thread when invoked with an interval greater than zero. This behavior starts the KeepAlive Thread prior to establishing a connection, depending on when the caller invokes setKeepAliveInterval().

Neither the ConnectionImpl class nor the SSHClient class interrupt the KeepAlive Thread, resulting in continued looping inside of KeepAlive.run() even after disconnecting and closing SSHClient as described in issue #506.

This pull request changes the behavior of KeepAlive.setKeepAliveInterval() to avoid starting the Thread. The SSHClient.onConnect() method checks whether the KeepAlive Thread is enabled and then calls start() to avoid unnecessary execution prior to a successful connection. The SSHClient.disconnect() method interrupts the KeepAlive Thread to ensure that it does not continue running. The KeepAliveThreadTerminationTest includes an additional method to verify the initial state of the KeepAlive Thread, as well as the state after connecting and disconnecting.

…ierynomus#506)

- Changed KeepAlive.setKeepAliveInterval() to avoid starting Thread
- Updated SSHClient.onConnect() to start KeepAlive Thread when enabled
- Updated SSHClient.disconnect() to interrupt KeepAlive Thread
- Updated KeepAliveThreadTerminationTest to verify state of KeepAlive Thread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants