diff options
author | Jeff Vander Stoep <jeffv@google.com> | 2023-02-16 15:24:49 +0100 |
---|---|---|
committer | Jeff Vander Stoep <jeffv@google.com> | 2023-02-16 15:24:49 +0100 |
commit | 61fa94f41808c820ca6be95f722a0ef6efdc2a35 (patch) | |
tree | 051937287f30fd49716ced0af7befbb00ec9d957 /src/sys/windows/iocp.rs | |
parent | 544dbb293255736fdafcca00c99e6f4b293c706a (diff) | |
download | mio-61fa94f41808c820ca6be95f722a0ef6efdc2a35.tar.gz |
Upgrade mio to 0.8.6
This project was upgraded with external_updater.
Usage: tools/external_updater/updater.sh update rust/crates/mio
For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
Test: TreeHugger
Change-Id: I5a8f9771f053ac1d65c11d2cd25dae4345a475d0
Diffstat (limited to 'src/sys/windows/iocp.rs')
-rw-r--r-- | src/sys/windows/iocp.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/sys/windows/iocp.rs b/src/sys/windows/iocp.rs index 142b6fc..262c8f2 100644 --- a/src/sys/windows/iocp.rs +++ b/src/sys/windows/iocp.rs @@ -224,17 +224,12 @@ impl CompletionStatus { #[inline] fn duration_millis(dur: Option<Duration>) -> u32 { if let Some(dur) = dur { - let dur_ms = dur.as_millis(); - // as_millis() truncates, so round nonzero <1ms timeouts up to 1ms. This avoids turning - // submillisecond timeouts into immediate reutrns unless the caller explictly requests that - // by specifiying a zero timeout. - let dur_ms = dur_ms - + if dur_ms == 0 && dur.subsec_nanos() != 0 { - 1 - } else { - 0 - }; - std::cmp::min(dur_ms, u32::MAX as u128) as u32 + // `Duration::as_millis` truncates, so round up. This avoids + // turning sub-millisecond timeouts into a zero timeout, unless + // the caller explicitly requests that by specifying a zero + // timeout. + let dur_ms = (dur + Duration::from_nanos(999_999)).as_millis(); + cmp::min(dur_ms, u32::MAX as u128) as u32 } else { u32::MAX } |