aboutsummaryrefslogtreecommitdiffstats
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
commit38d5af73d40f1d94ef141b4e5991c7c7182a0028 (patch)
tree27a18265317f3d9f092e5fc2563cb1af4ed48915 /src/remake/switch.rs
parent7aa649e5272e3e25f43e7fd4cb11516b0c882b03 (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,