From afe6b828101d762c7fd2c4dc2279862ba297075b 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] Do not panic when join handle is canceled --- tunnel-obfuscation/src/shadowsocks.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tunnel-obfuscation/src/shadowsocks.rs b/tunnel-obfuscation/src/shadowsocks.rs index eb56a3a63cf9..79e0df4380b2 100644 --- a/tunnel-obfuscation/src/shadowsocks.rs +++ b/tunnel-obfuscation/src/shadowsocks.rs @@ -228,10 +228,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")]