From ef4ec226ef720f4c3bdba5ae534465f67cda04ee Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Oct 2026 23:38:22 +0100 Subject: remake worker wakes up when vote is due --- src/remake/switch.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/remake/switch.rs') diff --git a/src/remake/switch.rs b/src/remake/switch.rs index ea56de6..6c90f44 100644 --- a/src/remake/switch.rs +++ b/src/remake/switch.rs @@ -54,8 +54,12 @@ pub(crate) async fn run_worker(host: H) { loop { // React promptly to changes of the records; the timer covers the switch delay. + // A vote waiting for its random delay (`vote`) is cast when due, not at the next + // tick: with a short voting period, a second can make it too late. + let vote_wait = host.remake().vote_wait(host.now_millis()); let should_check = tokio::select! { _ = tick.tick() => true, + _ = tokio::time::sleep(vote_wait.unwrap_or_default()), if vote_wait.is_some() => true, received = changes.recv(), if !changes_closed => match received { Ok(set) => set.paths.iter().any(|path| paths_related(path, &records_dir)), Err(broadcast::error::RecvError::Lagged(_)) => true, -- cgit v1.3.1