From cf189c58d65b44a485e574974ece6384885d8b47 Mon Sep 17 00:00:00 2001 From: EAimTY Date: Sun, 5 Feb 2023 19:17:54 +0900 Subject: [PATCH] fix client heartbeat condition, properly --- tuic-client/src/connection.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tuic-client/src/connection.rs b/tuic-client/src/connection.rs index 16296ad..dadd728 100644 --- a/tuic-client/src/connection.rs +++ b/tuic-client/src/connection.rs @@ -393,12 +393,14 @@ impl Connection { loop { time::sleep(heartbeat).await; - let task_count = self.model.task_connect_count() + self.model.task_associate_count(); - - if self.is_closed() || task_count == 0 { + if self.is_closed() { break; } + if self.model.task_connect_count() + self.model.task_associate_count() == 0 { + continue; + } + match self.model.heartbeat().await { Ok(()) => {} Err(err) => eprintln!("{err}"),