summaryrefslogtreecommitdiffstats
path: root/src/remake/switch.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-26 23:38:22 +0100
committertv <tv@krebsco.de>2026-10-26 23:38:22 +0100
commitef4ec226ef720f4c3bdba5ae534465f67cda04ee (patch)
tree6a6882afa9a3a48ab42ad01178a0d7ea7ee8fc3e /src/remake/switch.rs
parentd9b97e010db43e7307d095f215a889c7b851683c (diff)
remake worker wakes up when vote is due
Diffstat (limited to 'src/remake/switch.rs')
-rw-r--r--src/remake/switch.rs4
1 files changed, 4 insertions, 0 deletions
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<H: Host>(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,