Skip to content

Commit

Permalink
tokio/interval: Fix overflow for interval tick
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
  • Loading branch information
lexnv committed Mar 4, 2025
1 parent a2b12bd commit 47ee3e1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tokio/src/time/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,12 @@ impl Interval {
// However, if a tick took excessively long and we are now behind,
// schedule the next tick according to how the user specified with
// `MissedTickBehavior`
let next = if now > timeout + Duration::from_millis(5) {

let next = if now
> timeout
.checked_add(Duration::from_millis(5))
.unwrap_or_else(Instant::far_future)
{
self.missed_tick_behavior
.next_timeout(timeout, now, self.period)
} else {
Expand Down

0 comments on commit 47ee3e1

Please sign in to comment.