Browse Source

Fix timeval in phy_wait for times greater than 1 second

Dario Nieuwenhuis 4 years ago
parent
commit
250450a678
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/phy/sys/mod.rs

+ 2 - 1
src/phy/sys/mod.rs

@@ -47,7 +47,8 @@ pub fn wait(fd: RawFd, duration: Option<Duration>) -> io::Result<()> {
         let mut timeout = libc::timeval { tv_sec: 0, tv_usec: 0 };
         let timeout_ptr =
             if let Some(duration) = duration {
-                timeout.tv_usec = (duration.total_millis() * 1_000) as libc::suseconds_t;
+                timeout.tv_sec = duration.secs() as libc::time_t;
+                timeout.tv_usec = (duration.millis() * 1_000) as libc::suseconds_t;
                 &mut timeout as *mut _
             } else {
                 ptr::null_mut()