From 900262b8f1f2436e924147ef6729a7b3a88918a1 Mon Sep 17 00:00:00 2001 From: Markus Pettersson Date: Fri, 13 Dec 2024 15:03:15 +0100 Subject: [PATCH] Remove `proc` argument to `parse_logger_status` --- talpid-core/src/split_tunnel/macos/process.rs | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/talpid-core/src/split_tunnel/macos/process.rs b/talpid-core/src/split_tunnel/macos/process.rs index 6a87a7d5f5d8..b2077de0c7f7 100644 --- a/talpid-core/src/split_tunnel/macos/process.rs +++ b/talpid-core/src/split_tunnel/macos/process.rs @@ -10,10 +10,9 @@ use libc::pid_t; use serde::Deserialize; use std::{ collections::{HashMap, HashSet}, - future::Future, io, path::PathBuf, - process::{ExitStatus, Stdio}, + process::Stdio, sync::{Arc, LazyLock, Mutex}, time::Duration, }; @@ -110,8 +109,7 @@ pub async fn has_full_disk_access() -> bool { let stderr = proc.stderr.take().unwrap(); drop(proc.stdin.take()); - let has_full_disk_access = - parse_logger_status(proc.wait(), stdout, stderr).await == NeedFda::No; + let has_full_disk_access = parse_logger_status(stdout, stderr).await == NeedFda::No; Ok::(has_full_disk_access) }) .await @@ -127,8 +125,6 @@ enum NeedFda { /// Return whether `proc` reports that full-disk access is unavailable based on its output /// If it cannot be determined that access is available, it is assumed to be available async fn parse_logger_status( - // TODO: Remove me - proc: impl Future>, stdout: impl AsyncRead + Unpin + Send + 'static, stderr: impl AsyncRead + Unpin + Send + 'static, ) -> NeedFda { @@ -559,7 +555,7 @@ fn check_os_version_support_inner(version: MacosVersion) -> Result<(), Error> { mod test { use super::*; - use std::{process::ExitStatus, time::Duration}; + use std::time::Duration; use talpid_platform_metadata::MacosVersion; use tokio::io::{simplex, AsyncWriteExt}; @@ -604,7 +600,6 @@ mod test { #[tokio::test] async fn test_parse_logger_status_missing_access() { let need_fda = parse_logger_status( - async { Ok(ExitStatus::default()) }, &[][..], b"ES_NEW_CLIENT_RESULT_ERR_NOT_PERMITTED\n".as_slice(), ) @@ -622,10 +617,6 @@ mod test { #[tokio::test] async fn test_parse_logger_status_timeout() { let need_fda = parse_logger_status( - async { - tokio::time::sleep(EARLY_FAIL_TIMEOUT + Duration::from_secs(10)).await; - Ok(ExitStatus::default()) - }, b"nothing to see here\n".as_slice(), b"nothing to see here\n".as_slice(), ) @@ -643,7 +634,6 @@ mod test { #[tokio::test] async fn test_parse_logger_status_immediate_exit() { let need_fda = parse_logger_status( - async { Ok(ExitStatus::default()) }, b"nothing to see here\n".as_slice(), b"nothing to see here\n".as_slice(), ) @@ -669,8 +659,7 @@ mod test { ); tokio::time::resume(); - let need_fda = - parse_logger_status(async { Ok(ExitStatus::default()) }, stdout, stderr).await; + let need_fda = parse_logger_status(stdout, stderr).await; tokio::time::pause(); @@ -691,8 +680,7 @@ mod test { let stdout = output("This will never be printed\n", Duration::MAX); let stderr = output("This will never be printed\n", Duration::MAX); - let need_fda = - parse_logger_status(async { Ok(ExitStatus::default()) }, stdout, stderr).await; + let need_fda = parse_logger_status(stdout, stderr).await; assert_eq!( need_fda,