Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Commit

Permalink
Fix timeout calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
blackbeam committed Apr 6, 2019
1 parent f468148 commit aaf4e2b
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
//!
//! To connect to a pipe server use [`PipeClient`](struct.PipeClient.html) structure.


use winapi::{
ctypes::*,
shared::{minwindef::*, ntdef::HANDLE, winerror::*},
Expand Down Expand Up @@ -391,8 +390,8 @@ impl PipeServer {
/// Defaults to None (infinite).
pub fn set_read_timeout(&mut self, read_timeout: Option<Duration>) {
self.read_timeout = read_timeout.map(|dur| {
let (val, overflowed) = dur.as_secs().overflowing_mul(1000);
if overflowed || val > 0xFFFFFFFF {
let val = dur.as_millis();
if val > 0xFFFFFFFF {
0xFFFFFFFF
} else {
val as u32
Expand All @@ -409,8 +408,8 @@ impl PipeServer {
/// Defaults to None (infinite).
pub fn set_write_timeout(&mut self, write_timeout: Option<Duration>) {
self.write_timeout = write_timeout.map(|dur| {
let (val, overflowed) = dur.as_secs().overflowing_mul(1000);
if overflowed || val > 0xFFFFFFFF {
let val = dur.as_millis();
if val > 0xFFFFFFFF {
0xFFFFFFFF
} else {
val as u32
Expand Down Expand Up @@ -637,8 +636,8 @@ impl PipeClient {
/// Defaults to None (infinite).
pub fn set_read_timeout(&mut self, read_timeout: Option<Duration>) {
self.read_timeout = read_timeout.map(|dur| {
let (val, overflowed) = dur.as_secs().overflowing_mul(1000);
if overflowed || val > 0xFFFFFFFF {
let val = dur.as_millis();
if val > 0xFFFFFFFF {
0xFFFFFFFF
} else {
val as u32
Expand All @@ -655,8 +654,8 @@ impl PipeClient {
/// Defaults to None (infinite).
pub fn set_write_timeout(&mut self, write_timeout: Option<Duration>) {
self.write_timeout = write_timeout.map(|dur| {
let (val, overflowed) = dur.as_secs().overflowing_mul(1000);
if overflowed || val > 0xFFFFFFFF {
let val = dur.as_millis();
if val > 0xFFFFFFFF {
0xFFFFFFFF
} else {
val as u32
Expand Down

0 comments on commit aaf4e2b

Please sign in to comment.