From 80bbe04559225b24e7ec37239cfdccab4a9ef6ba Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Tue, 22 Dec 2020 22:37:14 +0800 Subject: [PATCH] hide the first balancer check info log --- .../src/local/loadbalancing/ping_balancer.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs b/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs index 456b0c53..468b301d 100644 --- a/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs +++ b/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs @@ -120,7 +120,7 @@ impl PingBalancerInner { assert!(!self.servers.is_empty(), "check PingBalancer without any servers"); if self.servers.len() > 1 { - self.check_once().await; + self.check_once(false).await; } } @@ -140,7 +140,7 @@ impl PingBalancerInner { } /// Check each servers' score and update the best server's index - async fn check_once(&self) { + async fn check_once(&self, print_switch: bool) { let mut vfut = Vec::with_capacity(self.servers.len()); for server in self.servers.iter() { @@ -179,7 +179,7 @@ impl PingBalancerInner { } self.best_tcp_idx.store(best_idx, Ordering::Release); - if best_idx != old_best_idx { + if print_switch && best_idx != old_best_idx { info!( "switched best TCP server from {} to {}", self.servers[old_best_idx].server_config().addr(), @@ -202,7 +202,7 @@ impl PingBalancerInner { } self.best_udp_idx.store(best_idx, Ordering::Release); - if best_idx != old_best_idx { + if print_switch && best_idx != old_best_idx { info!( "switched best UDP server from {} to {}", self.servers[old_best_idx].server_config().addr(), @@ -214,7 +214,7 @@ impl PingBalancerInner { async fn checker_task_real(&self) { loop { - self.check_once().await; + self.check_once(true).await; time::sleep(Duration::from_secs(DEFAULT_CHECK_INTERVAL_SEC)).await; } }