Skip to content

Commit

Permalink
Fix panic when cancelling join handle
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Aug 29, 2024
1 parent 012ed67 commit 2ca29ec
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tunnel-obfuscation/src/shadowsocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ async fn run_obfuscation(
}

client.abort();
let _ = client.await;
server.abort();
let _ = server.await;

Ok(())
}
Expand Down Expand Up @@ -228,10 +226,11 @@ impl Obfuscator for Shadowsocks {
}

async fn run(self: Box<Self>) -> 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")]
Expand Down

0 comments on commit 2ca29ec

Please sign in to comment.