bugfix: Prevent large timeouts from causing panics (#71)

This commit is contained in:
John Nunley 2023-01-08 03:35:46 +00:00 committed by GitHub
parent 181acc67d0
commit dc4c5b4ec0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -213,7 +213,7 @@ impl Poller {
timeout
);
let deadline = timeout.map(|t| Instant::now() + t);
let deadline = timeout.and_then(|t| Instant::now().checked_add(t));
events.inner.clear();

View File

@ -95,7 +95,7 @@ impl Poller {
/// included in the `events` list nor contribute to the returned count.
pub fn wait(&self, events: &mut Events, timeout: Option<Duration>) -> io::Result<()> {
log::trace!("wait: handle={:?}, timeout={:?}", self.handle, timeout);
let deadline = timeout.map(|t| Instant::now() + t);
let deadline = timeout.and_then(|t| Instant::now().checked_add(t));
loop {
// Convert the timeout to milliseconds.