feat: return exact timestamp when next action is required#213
Merged
thomaseizinger merged 3 commits intoJul 14, 2026
Conversation
Extract each timer into a method on `Timers` that returns the exact `Instant` at which it is due, and use them to make `next_timer_update` report the precise next wake-up together with a reason for it. Callers can now drive the state machine purely by polling at the returned instant instead of on a fixed interval. `clear_all` now takes the current time instead of reading the wall clock, keeping the timer state pure so the reported instants stay deterministic after a connection is wiped. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XsRkNsA4r812CDfwPH8ehF
`Sim::advance` no longer polls once per tick. It jumps straight to the earliest instant either peer announces via `next_timer_update`, which asserts that the announced instants are complete: polling only at them reproduces the exact behaviour of polling once a second. A small nudge keeps forward progress across the strictly-after session-expiry boundary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XsRkNsA4r812CDfwPH8ehF
Cover the guarantee restored in #104: sending on a session older than REKEY_AFTER_TIME arms a timer whose deadline has already elapsed, and `next_timer_update` must clamp that to the last known now rather than hand the caller an instant it can never sleep until. The jump-based harness clamps its own step, so this contract was otherwise untested. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XsRkNsA4r812CDfwPH8ehF
jamilbk
approved these changes
Jul 14, 2026
thomaseizinger
pushed a commit
to firezone/firezone
that referenced
this pull request
Jul 14, 2026
boringtun's `next_timer_update` now reports the exact instant of the next required timer action, so the tunnel no longer needs polling on a fixed one-second interval. Bump boringtun to pick that up and query it directly when computing the next timeout. Related: firezone/boringtun#213 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XsRkNsA4r812CDfwPH8ehF
thomaseizinger
pushed a commit
to firezone/firezone
that referenced
this pull request
Jul 14, 2026
boringtun's `next_timer_update` now reports the exact instant of the next required timer action, so the tunnel no longer needs polling on a fixed one-second interval. Bump boringtun to pick that up and query it directly when computing the next timeout. Related: firezone/boringtun#213 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XsRkNsA4r812CDfwPH8ehF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
next_timer_updatenow reports the exact instant of the next required action (and the reason for it) rather than an approximation, so callers can drive the tunnel purely off the returned instant instead of polling once a second. The timer test suite is updated to do exactly that, which doubles as an assertion that the reported instants are complete: polling only at them reproduces the once-a-second behaviour.This allows callers to properly suspend until the next event instead of having to wake up once a second to update boringtun's timers.