Skip to content

Commit 70c8183

Browse files
committed
Do not panic when join handle is canceled
1 parent fb1f4e1 commit 70c8183

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tunnel-obfuscation/src/shadowsocks.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,11 @@ impl Obfuscator for Shadowsocks {
227227
}
228228

229229
async fn run(self: Box<Self>) -> crate::Result<()> {
230-
self.server
231-
.await
232-
.expect("server handle panicked")
233-
.map_err(crate::Error::RunShadowsocksObfuscator)
230+
match self.server.await {
231+
Ok(result) => result.map_err(crate::Error::RunShadowsocksObfuscator),
232+
Err(_err) if _err.is_cancelled() => Ok(()),
233+
Err(_err) => panic!("server handle panicked"),
234+
}
234235
}
235236

236237
#[cfg(target_os = "android")]

0 commit comments

Comments
 (0)