mirror of https://github.com/smol-rs/polling
bugfix: Prevent large timeouts from causing panics (#71)
This commit is contained in:
parent
181acc67d0
commit
dc4c5b4ec0
|
@ -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();
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue