mirror of https://github.com/smol-rs/polling
Use saturating_add to prevent overflow
This commit is contained in:
parent
d4667889b4
commit
8b656241d5
|
@ -24,7 +24,7 @@ log = "0.4.11"
|
|||
libc = "0.2.77"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
wepoll-sys = "2.0.0"
|
||||
wepoll-sys = { path = "../wepoll" }
|
||||
winapi = { version = "0.3.9", features = ["ioapiset", "winsock2"] }
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -81,8 +81,8 @@ impl Poller {
|
|||
Some(t) => {
|
||||
// Round up to a whole millisecond.
|
||||
let mut ms = t.as_millis().try_into().unwrap_or(std::u64::MAX);
|
||||
if Duration::from_millis(ms) < t {
|
||||
ms += 1;
|
||||
if Duration::from_millis(ms as u64) < t {
|
||||
ms = ms.saturating_add(1);
|
||||
}
|
||||
ms.try_into().unwrap_or(std::i32::MAX)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue