Skip to content

Commit

Permalink
Fix panic caused by join handle being awaited twice
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Sep 2, 2024
1 parent 8a837ba commit 338d082
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 338d082

Please sign in to comment.