From 768da4fd62b390014fcaf55e23dbb45ca61ad79b Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 19:50:24 +0000 Subject: time: a wait seam the control loops call through The dispatcher tick, watcher tick, SSE poll, agent watchdog and remote keepalive each slept on the wall clock in their own slice loop, so every test that wanted a tick waited for real time. They call crate::time::wait/sleep now, which is the same real sleep in a production build and a virtual clock advance under test-support: a test that takes the clock owns it, and threads it spawns inherit it. production_surface checks the virtual path is compiled out and that no control loop went back to std::thread::sleep. --- src/http/mod.rs | 8 ++++---- src/http/sse.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/http') diff --git a/src/http/mod.rs b/src/http/mod.rs index 7beeff4..0d78a00 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -97,19 +97,19 @@ pub fn spawn(cfg: Config, db: Db) -> std::io::Result { eprintln!("aur-build listening on http://{addr}"); let handle = std::thread::Builder::new() .name("http-accept".into()) - .spawn(move || { + .spawn(crate::time::inherit(move || { for request in server.incoming_requests() { let state = state.clone(); std::thread::Builder::new() .name("http-conn".into()) - .spawn(move || { + .spawn(crate::time::inherit(move || { if let Err(e) = serve(state, request) { eprintln!("http: {e}"); } - }) + })) .ok(); } - })?; + }))?; Ok(Server { handle, addr }) } diff --git a/src/http/sse.rs b/src/http/sse.rs index e4a5e6a..39266be 100644 --- a/src/http/sse.rs +++ b/src/http/sse.rs @@ -91,7 +91,7 @@ impl Read for LogTail { self.finish(); continue; } - std::thread::sleep(POLL); + crate::time::sleep(POLL); self.since_keepalive += POLL; if self.since_keepalive >= KEEPALIVE { self.since_keepalive = Duration::ZERO; -- cgit v1.2.3