From 0b8f24a92eeb150e0c6b5ffe8649264d4ea7538f Mon Sep 17 00:00:00 2001 From: huzibaca Date: Tue, 1 Oct 2024 00:27:08 +0800 Subject: [PATCH] chore: optimize lock --- src-tauri/src/core/sysopt.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src-tauri/src/core/sysopt.rs b/src-tauri/src/core/sysopt.rs index af3fb0c..ff7335b 100644 --- a/src-tauri/src/core/sysopt.rs +++ b/src-tauri/src/core/sysopt.rs @@ -339,18 +339,10 @@ impl Sysopt { /// read config from file directly pub fn guard_proxy(&self) { use tokio::time::{sleep, Duration}; - let guard_state = self.guard_state.clone(); tauri::async_runtime::spawn(async move { - // if it is running, exit - let mut state = guard_state.lock().await; - if *state { - return; - } - *state = true; - drop(state); - + let _ = guard_state.lock().await; // default duration is 10s let mut wait_secs = 10u64; @@ -402,10 +394,6 @@ impl Sysopt { log_err!(sysproxy.set_system_proxy()); } } - - let mut state = guard_state.lock().await; - *state = false; - drop(state); }); } }