summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2024-12-19 08:26:56 +0100
committerDavid Lönnhager <david.l@mullvad.net>2024-12-19 10:04:32 +0100
commit977dd4a37eaa80817761d88f348b4e332f1212ae (patch)
tree2f2652c83e4ef179bbddc429185ad91fad44ce8b
parentb8acc74a96aba8bc1ece2a063ef09f6ab219744c (diff)
downloadmullvadvpn-977dd4a37eaa80817761d88f348b4e332f1212ae.tar.xz
mullvadvpn-977dd4a37eaa80817761d88f348b4e332f1212ae.zip
Do not block during ephemeral peer exchange
-rw-r--r--talpid-wireguard/src/ephemeral.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/talpid-wireguard/src/ephemeral.rs b/talpid-wireguard/src/ephemeral.rs
index c8df8835e7..4185440c85 100644
--- a/talpid-wireguard/src/ephemeral.rs
+++ b/talpid-wireguard/src/ephemeral.rs
@@ -121,7 +121,7 @@ async fn config_ephemeral_peers_inner(
// NOTE: This one often fails with multihop on Windows, even though the handshake afterwards
// succeeds. So we try anyway if it fails.
#[cfg(force_wireguard_handshake)]
- let _ = establish_tunnel_connection(tunnel, connectivity).await;
+ let _ = establish_tunnel_connection(tunnel, connectivity);
let ephemeral_private_key = PrivateKey::new_from_random();
let close_obfs_sender = close_obfs_sender.clone();
@@ -162,7 +162,7 @@ async fn config_ephemeral_peers_inner(
.await?;
#[cfg(force_wireguard_handshake)]
- establish_tunnel_connection(tunnel, connectivity).await?;
+ establish_tunnel_connection(tunnel, connectivity)?;
let entry_ephemeral_peer = request_ephemeral_peer(
retry_attempt,
@@ -300,16 +300,17 @@ async fn reconfigure_tunnel(
/// Ensure that the WireGuard tunnel works. This is useful after updating the WireGuard config, to
/// force a WireGuard handshake. This should reduce the number of PQ timeouts.
#[cfg(force_wireguard_handshake)]
-async fn establish_tunnel_connection(
+fn establish_tunnel_connection(
tunnel: &Arc<AsyncMutex<Option<TunnelType>>>,
connectivity: &mut connectivity::Check<connectivity::Cancellable>,
) -> Result<(), CloseMsg> {
use talpid_types::ErrorExt;
- let shared_tunnel = tunnel.lock().await;
- let tunnel = shared_tunnel.as_ref().expect("tunnel was None");
- let ping_result = connectivity.establish_connectivity(tunnel);
- drop(shared_tunnel);
+ let ping_result = tokio::task::block_in_place(|| {
+ let shared_tunnel = tunnel.blocking_lock();
+ let tunnel = shared_tunnel.as_ref().expect("tunnel was None");
+ connectivity.establish_connectivity(tunnel)
+ });
match ping_result {
Ok(true) => Ok(()),