From c776e574d4daca80f68abb3583b6ea27064b3265 Mon Sep 17 00:00:00 2001 From: Jared Baur Date: Thu, 10 Jul 2025 10:08:38 -0700 Subject: [PATCH] switch-to-configuration-ng: add timeout while waiting for settle Without a timeout, we (switch-to-configuration) could be stuck in a loop if we continue receiving D-Bus signals for new systemd events. This could indicate a problem elsewhere on the machine, however we shouldn't allow this to cause switch-to-configuration to get stuck. --- .../sw/switch-to-configuration-ng/src/src/main.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs b/pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs index 4fa8bc50d203..f4d339ccf60e 100644 --- a/pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs +++ b/pkgs/by-name/sw/switch-to-configuration-ng/src/src/main.rs @@ -1894,10 +1894,17 @@ won't take effect until you reboot the system. // // Wait for events from systemd to settle. process() will return true if we have received any // messages on the bus. - while dbus_conn - .process(Duration::from_millis(250)) - .unwrap_or_default() - {} + let mut waited = Duration::from_millis(0); + let wait_interval = Duration::from_millis(250); + let max_wait = Duration::from_secs(90); + log::debug!("waiting for systemd events to settle"); + while dbus_conn.process(wait_interval).unwrap_or_default() { + waited += wait_interval; + if waited >= max_wait { + log::debug!("timed out waiting systemd events to settle"); + break; + } + } let new_active_units = get_active_units(&systemd)?;