瀏覽代碼

Fix timeval in phy_wait for times greater than 1 second

Dario Nieuwenhuis 4 年之前
父節點
當前提交
250450a678
共有 1 個文件被更改,包括 2 次插入1 次删除
  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()