From 362f020a12cebc910a1c4f17162ac13328e17681 Mon Sep 17 00:00:00 2001 From: Markus Pettersson Date: Tue, 10 Oct 2023 13:18:45 +0200 Subject: [PATCH] Get rid of nested `Arc`s --- talpid-openvpn/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/talpid-openvpn/src/lib.rs b/talpid-openvpn/src/lib.rs index 28578a2146db..2e3882fb37bf 100644 --- a/talpid-openvpn/src/lib.rs +++ b/talpid-openvpn/src/lib.rs @@ -169,7 +169,7 @@ pub struct OpenVpnMonitor { >, abort_spawn: futures::future::AbortHandle, - child: Arc>>>, + child: Arc>>, proxy_monitor: Option>, closed: Arc, /// Keep the `TempFile` for the user-pass file in the struct, so it's removed on drop. @@ -569,7 +569,7 @@ impl OpenVpnMonitor { .await .expect("spawn task panicked") { - Ok(Ok(child)) => Arc::new(child), + Ok(Ok(child)) => child, Ok(Err(error)) => { self.closed.swap(true, Ordering::SeqCst); return WaitResult::Preparation(Err(error)); @@ -583,13 +583,13 @@ impl OpenVpnMonitor { } { - self.child.lock().await.replace(child.clone()); + self.child.lock().await.replace(child); } let event_server_abort_tx = self.event_server_abort_tx.clone(); let kill_child = async move { - let result = child.wait().await; + let result = self.child.lock().await.as_ref().unwrap().wait().await; let closed = self.closed.load(Ordering::SeqCst); let result = WaitResult::Child(result, closed); event_server_abort_tx.trigger(); @@ -722,7 +722,7 @@ impl OpenVpnMonitor { /// A handle to an `OpenVpnMonitor` for closing it. #[derive(Debug, Clone)] pub struct OpenVpnCloseHandle { - child: Arc>>>, + child: Arc>>, abort_spawn: futures::future::AbortHandle, closed: Arc, }