From c88219b7696013b31b0a62c34a1865e303c1619c Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Sun, 30 Jul 2023 15:07:17 +0530 Subject: [PATCH] retry _get_values_of_seat0 function to fix connection refused error Signed-off-by: Sahil Yeole --- libs/hbb_common/src/platform/linux.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/hbb_common/src/platform/linux.rs b/libs/hbb_common/src/platform/linux.rs index 89c96799d..2b14fcd67 100644 --- a/libs/hbb_common/src/platform/linux.rs +++ b/libs/hbb_common/src/platform/linux.rs @@ -133,6 +133,8 @@ pub fn get_values_of_seat0_with_gdm_wayland(indices: &[usize]) -> Vec { } fn _get_values_of_seat0(indices: &[usize], ignore_gdm_wayland: bool) -> Vec { + let mut retry_attempt = 0; + loop{ if let Ok(output) = run_loginctl(None) { for line in String::from_utf8_lossy(&output.stdout).lines() { if line.contains("seat0") { @@ -172,7 +174,13 @@ fn _get_values_of_seat0(indices: &[usize], ignore_gdm_wayland: bool) -> Vec= 1 { + return line_values(indices, ""); + } + // Increment the retry_attempt counter and wait for 5 seconds before retrying + retry_attempt += 1; + std::thread::sleep(Duration::from_secs(5)); + } } pub fn is_active(sid: &str) -> bool {