From 055e12747571aa28770051ec744b9c3e7c995bc3 Mon Sep 17 00:00:00 2001 From: alterdekim Date: Sun, 13 Oct 2024 21:02:36 +0300 Subject: [PATCH] modified: src/client.rs --- src/client.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/client.rs b/src/client.rs index 6ee3ceb..16f8b47 100644 --- a/src/client.rs +++ b/src/client.rs @@ -46,12 +46,13 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, close_toke let cipher_shared: Arc>> = Arc::new(Mutex::new(None)); - let cancel_dr = close_token.clone(); + let cancel_dr = subtasks_quit.clone(); let dev_read_task = tokio::spawn(async move { let mut buf = vec![0; 1400]; // mtu loop { + let sf = cancel_dr.lock().unwrap(); tokio::select! { - _ = subtasks_quit.lock().unwrap().cancelled() => { + _ = sf.cancelled() => { info!("Cancellation token has been thrown dev_read_task"); return; } @@ -62,19 +63,21 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, close_toke } } }; + drop(sf); } }); let priv_key = BASE64_STANDARD.decode(client_config.client.private_key).unwrap(); let cipher_shared_clone = cipher_shared.clone(); - let cancel_sr = close_token.clone(); + let cancel_sr = subtasks_quit.clone(); let sock_read_task = tokio::spawn(async move { let mut buf = vec![0; 4096]; loop { + let sf = cancel_sr.lock().unwrap(); tokio::select! { - _ = subtasks_quit.lock().unwrap().cancelled() => { + _ = sf.cancelled() => { info!("Cancellation token has been thrown sock_read_task"); return; } @@ -121,6 +124,7 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, close_toke } } }; + drop(sf); } });