From 61fa94f41808c820ca6be95f722a0ef6efdc2a35 Mon Sep 17 00:00:00 2001 From: Jeff Vander Stoep Date: Thu, 16 Feb 2023 15:24:49 +0100 Subject: 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 --- src/sys/windows/iocp.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/sys/windows/iocp.rs') 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) -> 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 } -- cgit v1.2.3