Skip to content

Fix CancelAsync Cause Deadlock - #1345

Merged
WojciechNagorski merged 9 commits into
sshnet:developfrom
zeotuan:cancelAsync
Mar 24, 2024
Merged

Fix CancelAsync Cause Deadlock#1345
WojciechNagorski merged 9 commits into
sshnet:developfrom
zeotuan:cancelAsync

Conversation

@zeotuan

@zeotuanzeotuan commented Mar 7, 2024

Copy link
Copy Markdown
Contributor

Fix CancelAsync causing deadlocking:

it now signal WaitHandle of Cancelled event after sending SIGTERM/SIGKILL signal to try to abort the request.

close#1147 and close#1023

@zeotuan
zeotuan marked this pull request as ready for review March 7, 2024 02:14

@Rob-HagueRob-Hague left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add a test for forceKill = true as well?

Comment threadtest/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs Outdated
Comment threadtest/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs Outdated
Comment threadsrc/Renci.SshNet/SshCommand.cs Outdated
/// </summary>
public void CancelAsync()
/// <param name="forceKill">if true send SIGKILL instead of SIGTERM.</param>
public void CancelAsync(bool forceKill = false)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we drop the Async suffix here (and obsolete CancelAsync) as it is not an async method. @WojciechNagorski?

@zeotuan
zeotuan requested a review from Rob-HagueMarch 21, 2024 22:55
Comment threadsrc/Renci.SshNet/SshCommand.cs Outdated
Comment threadsrc/Renci.SshNet/Common/SshOperationCancelledException.cs Outdated

@WojciechNagorskiWojciechNagorski left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I don't have much time for this project at the moment. Only PRs that have @Rob-Hague's approval are verified and merged by me.

This was referenced Aug 12, 2026
Sign up for freeto 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.

CancelAsync does not cancel the command started by BeginExecute and blocks execution Is it possible to cancel SshCommand?

3 participants

@zeotuan@Rob-Hague@WojciechNagorski