From e40672592cdb7b01b0a7b8b8571fab909375604c Mon Sep 17 00:00:00 2001 From: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Date: Sun, 8 Sep 2024 14:39:09 +1000 Subject: [PATCH 1/4] Add optional dependency tracing Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index e671ac66e..71d76228f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,8 @@ openssh-mux-client = { version = "0.17.0", optional = true } libc = "0.2.137" +tracing = { version = "0.1", optional = true } + [dev-dependencies] regex = "1" tokio = { version = "1", features = [ "full" ] } From d6aff59c1aad74f5abb91e708987d88ffc51b7cf Mon Sep 17 00:00:00 2001 From: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Date: Sun, 8 Sep 2024 14:42:06 +1000 Subject: [PATCH 2/4] Add logging for ::drop Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> --- src/process_impl/session.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/process_impl/session.rs b/src/process_impl/session.rs index c9d021865..7188ffc6a 100644 --- a/src/process_impl/session.rs +++ b/src/process_impl/session.rs @@ -226,10 +226,14 @@ impl Drop for Session { None => return, }; - let _ = self + let _res = self .new_std_cmd(&["-O", "exit"]) .stdout(Stdio::null()) .stderr(Stdio::null()) .status(); + #[cfg(feature = "tracing")] + if let Err(err) = _res { + tracing::error!("Closing ssh session failed: {}", err); + } } } From 16cff48fbd7c31bf5ab5593176b7a8bc38ebdd39 Mon Sep 17 00:00:00 2001 From: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Date: Sun, 8 Sep 2024 14:44:54 +1000 Subject: [PATCH 3/4] Add tracing to ::drop Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> --- src/native_mux_impl/session.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/native_mux_impl/session.rs b/src/native_mux_impl/session.rs index 1ee719f0a..5e7eb9aa8 100644 --- a/src/native_mux_impl/session.rs +++ b/src/native_mux_impl/session.rs @@ -105,6 +105,10 @@ impl Drop for Session { None => return, }; - let _ = shutdown_mux_master(&self.ctl); + let _res = shutdown_mux_master(&self.ctl); + #[cfg(feature = "tracing")] + if let Err(err) = _res { + tracing::error!("Failed to close ssh session: {}", err); + } } } From 52adf1087d29b4a3aef15009b82079f975a6b739 Mon Sep 17 00:00:00 2001 From: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Date: Sun, 8 Sep 2024 14:49:09 +1000 Subject: [PATCH 4/4] Unify drop logging msg Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> --- src/native_mux_impl/session.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native_mux_impl/session.rs b/src/native_mux_impl/session.rs index 5e7eb9aa8..23b4e11d4 100644 --- a/src/native_mux_impl/session.rs +++ b/src/native_mux_impl/session.rs @@ -108,7 +108,7 @@ impl Drop for Session { let _res = shutdown_mux_master(&self.ctl); #[cfg(feature = "tracing")] if let Err(err) = _res { - tracing::error!("Failed to close ssh session: {}", err); + tracing::error!("Closing ssh session failed: {}", err); } } }