Skip to content

Commit

Permalink
Prevent negative duration. Fixes tokio-rs#27, somewhat similar to tok…
Browse files Browse the repository at this point in the history
  • Loading branch information
mwanner committed Oct 15, 2017
1 parent d7bd58f commit 32f994f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ impl Future for Sleep {
// An wakeup request has not yet been sent to the timer. Before
// doing so, check to ensure that the requested duration does
// not exceed the `max_timeout` duration
if (self.when - Instant::now()) > *self.timer.worker.max_timeout() {
let now = Instant::now();
if self.when > now && (self.when - now) > *self.timer.worker.max_timeout() {
return Err(TimerError::TooLong);
}

Expand Down

0 comments on commit 32f994f

Please # to comment.