From df6f839acea051022c92d1dba70ecda258f3ed75 Mon Sep 17 00:00:00 2001 From: Markus Pettersson Date: Tue, 7 Jan 2025 15:54:35 +0100 Subject: [PATCH] fixup! Fix bug where `block_on` was called from an async context --- talpid-wireguard/src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/talpid-wireguard/src/lib.rs b/talpid-wireguard/src/lib.rs index 7dcf7fe57872..4c3a64dc60e5 100644 --- a/talpid-wireguard/src/lib.rs +++ b/talpid-wireguard/src/lib.rs @@ -490,7 +490,13 @@ impl WireguardMonitor { // timing out on Windows for 2024.9-beta1. These verbose data usage logs are // a temporary measure to help us understand the issue. They can be removed // if the issue is resolved. - log_tunnel_data_usage(&config, &tunnel).await; + if let Err(err) = + tokio::task::spawn_blocking(move || log_tunnel_data_usage(&config, &tunnel)) + .await + { + log::error!("Failed to log tunnel data during setup phase"); + log::error!("{err}"); + } return Err(e); } @@ -1033,6 +1039,8 @@ enum CloseMsg { pub(crate) trait Tunnel: Send { fn get_interface_name(&self) -> String; fn stop(self: Box) -> std::result::Result<(), TunnelError>; + /// # Note + /// This function should *not* be called from within an async context. fn get_tunnel_stats(&self) -> std::result::Result; fn set_config<'a>( &'a mut self,