From 338d082e03d2b12f28aec3f71ea13e387090ec09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Mon, 26 Aug 2024 16:35:24 +0200 Subject: [PATCH] Fix panic caused by join handle being awaited twice --- tunnel-obfuscation/src/shadowsocks.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tunnel-obfuscation/src/shadowsocks.rs b/tunnel-obfuscation/src/shadowsocks.rs index eb56a3a63cf9..f40ee9d92ae8 100644 --- a/tunnel-obfuscation/src/shadowsocks.rs +++ b/tunnel-obfuscation/src/shadowsocks.rs @@ -115,9 +115,7 @@ async fn run_obfuscation( } client.abort(); - let _ = client.await; server.abort(); - let _ = server.await; Ok(()) } @@ -228,10 +226,11 @@ impl Obfuscator for Shadowsocks { } async fn run(self: Box) -> crate::Result<()> { - self.server - .await - .expect("server handle panicked") - .map_err(crate::Error::RunShadowsocksObfuscator) + match self.server.await { + Ok(result) => result.map_err(crate::Error::RunShadowsocksObfuscator), + Err(_err) if _err.is_cancelled() => Ok(()), + Err(_err) => panic!("server handle panicked"), + } } #[cfg(target_os = "android")]