From f49cd9f54844ab59884f6a2d936535ab69d95aba Mon Sep 17 00:00:00 2001 From: Igor Milavec Date: Sat, 19 Mar 2022 00:46:20 +0100 Subject: [PATCH 1/3] Use ExceptionDispatchInfo to retain call stack in Session.WaitOnHandle() --- src/Renci.SshNet/Session.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Renci.SshNet/Session.cs b/src/Renci.SshNet/Session.cs index 0846cb2cd..abae03a22 100644 --- a/src/Renci.SshNet/Session.cs +++ b/src/Renci.SshNet/Session.cs @@ -974,6 +974,9 @@ internal void WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout) switch (WaitHandle.WaitAny(waitHandles, timeout)) { case 0: +#if !NET35 && !NET40 + System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(_exception).Throw(); +#endif throw _exception; case 1: throw new SshConnectionException("Client not connected."); From 15a01fac958e8c3ff9965396fa7732eb39f54e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Nag=C3=B3rski?= Date: Fri, 15 Sep 2023 08:45:08 +0200 Subject: [PATCH 2/3] merge --- src/Renci.SshNet/Session.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Renci.SshNet/Session.cs b/src/Renci.SshNet/Session.cs index a7735838c..790b6e27b 100644 --- a/src/Renci.SshNet/Session.cs +++ b/src/Renci.SshNet/Session.cs @@ -992,9 +992,7 @@ internal void WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout) switch (signaledElement) { case 0: -#if !NET35 && !NET40 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(_exception).Throw(); -#endif throw _exception; case 1: throw new SshConnectionException("Client not connected."); From 035983f3674c37d62d4c251e6a0e0d6a8f484142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Nag=C3=B3rski?= Date: Fri, 15 Sep 2023 09:44:22 +0200 Subject: [PATCH 3/3] Update src/Renci.SshNet/Session.cs Co-authored-by: Rob Hague --- src/Renci.SshNet/Session.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Renci.SshNet/Session.cs b/src/Renci.SshNet/Session.cs index 790b6e27b..257cf8c2c 100644 --- a/src/Renci.SshNet/Session.cs +++ b/src/Renci.SshNet/Session.cs @@ -993,7 +993,7 @@ internal void WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout) { case 0: System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(_exception).Throw(); - throw _exception; + break; case 1: throw new SshConnectionException("Client not connected."); case 2: