diff options
| author | tv <tv@krebsco.de> | 2026-10-31 06:54:59 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 06:54:59 +0100 |
| commit | c5f743ef0f91e4afd0661824d4ec7df1483dcbad (patch) | |
| tree | e5b5cdafb405c5674b057cc6d1c27f3ff7226a13 /src/swarm/skew.rs | |
| parent | 1cb2ef3f00e695a414de87acfec090dfde749934 (diff) | |
propagate clock figures
Diffstat (limited to 'src/swarm/skew.rs')
| -rw-r--r-- | src/swarm/skew.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/swarm/skew.rs b/src/swarm/skew.rs index 1b98ff5..af11e5e 100644 --- a/src/swarm/skew.rs +++ b/src/swarm/skew.rs @@ -1,8 +1,9 @@ //! Whether this node's clock agrees with its peers' (`Transport::clock_offset`, from //! their PONGs). Each peer's clock is known within half a round trip; this node's own //! is off when it differs from most of its peers' by more than `--clock-skew-warn` for -//! sure, then the log says so (every `WARN_EVERY` while it lasts). A diagnostic only: -//! setting clocks is the operating system's (NTP). +//! sure, then the log says so (every `WARN_EVERY` while it lasts). Clocks are the +//! operating system's to set (NTP); the propagation figures only take this node's own +//! offset off (`AppState::clock_ahead_ms`). //! //! Two nodes alone can't tell whose clock is off: each warns. @@ -75,10 +76,16 @@ pub(crate) async fn measure(state: &AppState) -> Skew { of(&offsets, state.clock_skew_warn) } -/// Says in the log when this node's clock is off, and when it agrees again. From the -/// peer worker, every few seconds. +/// Notes how far this node's clock is ahead of its peers' (`AppState::clock_ahead_ms`), +/// and says in the log when it is off, and when it agrees again. From the peer worker, +/// every few seconds. pub(crate) async fn check(state: &AppState) { let skew = measure(state).await; + if let Some(offset_ms) = skew.offset_ms { + state + .clock_ahead_ms + .store(offset_ms, std::sync::atomic::Ordering::Relaxed); + } let now = Instant::now(); let mut warned = state.clock_skew_warned.lock_or_recover(); if skew.off { |
