Skip to content

Commit 5335405

Browse files
committed
fix(server): log events applied by the signal pump and report failures once
Device events applied by the pump were dropped, so they never reached the device-timing logs that the transaction path writes. A persistent failure also logged on every tick.
1 parent 5ddb5a2 commit 5335405

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

‎apps/vds-server/src/lib.rs‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,16 +288,38 @@ async fn serve(config: ServerConfig) -> Result<(), ServerError> {
288288
}
289289
}
290290

291+
/// Interval of the live-server due-event pump.
292+
const SIGNAL_PUMP_INTERVAL: std::time::Duration = std::time::Duration::from_millis(2);
293+
291294
/// Applies due device events on the live server so timer-driven signals reach
292295
/// their connections without waiting for another bus transaction.
296+
///
297+
/// Device schedulers are evaluated lazily, only inside that device's own
298+
/// transactions. A sensor that raises DRDY when a timer expires would otherwise
299+
/// stay silent until the next SPI/I2C access, which never comes while the
300+
/// application waits for the edge. The pump runs only when a topology is
301+
/// attached. Events it applies are logged exactly like transaction-path events.
293302
fn spawn_signal_pump(registry: Arc<DeviceRegistry>) {
294303
tokio::spawn(async move {
295-
let mut interval = tokio::time::interval(std::time::Duration::from_millis(2));
304+
let mut interval = tokio::time::interval(SIGNAL_PUMP_INTERVAL);
296305
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay);
306+
let mut failing = false;
297307
loop {
298308
interval.tick().await;
299-
if let Err(error) = registry.run_due_events() {
300-
warn!(component = "signals", %error, "signal pump failed");
309+
match registry.run_due_events() {
310+
Ok(events) => {
311+
failing = false;
312+
for (device_id, event) in events {
313+
log_device_events(&device_id, std::slice::from_ref(&event));
314+
}
315+
}
316+
Err(error) => {
317+
// Report a persistent failure once instead of every tick.
318+
if !failing {
319+
warn!(component = "signals", %error, "signal pump failed");
320+
}
321+
failing = true;
322+
}
301323
}
302324
}
303325
});

0 commit comments

Comments
 (0)