From dbf4b0270507aa0958c63e17dfd98fad852f594f Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Tue, 27 Dec 2016 19:37:11 +0200 Subject: [PATCH] Dispose streams when exec channel is closed instead of flushing Flushing PipeStream when the other end has been closed causes a deadlock and it doesn't make much sense given the closed state. --- src/Renci.SshNet/SshCommand.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Renci.SshNet/SshCommand.cs b/src/Renci.SshNet/SshCommand.cs index 37e91da08..d8b2e69cd 100644 --- a/src/Renci.SshNet/SshCommand.cs +++ b/src/Renci.SshNet/SshCommand.cs @@ -398,13 +398,15 @@ private void Channel_Closed(object sender, ChannelEventArgs e) var outputStream = OutputStream; if (outputStream != null) { - outputStream.Flush(); + outputStream.Dispose(); + OutputStream = null; } var extendedOutputStream = ExtendedOutputStream; if (extendedOutputStream != null) { - extendedOutputStream.Flush(); + extendedOutputStream.Dispose(); + ExtendedOutputStream = null; } _asyncResult.IsCompleted = true;