From: Ian Jackson Date: Sat, 20 Mar 2021 19:20:50 +0000 (+0000) Subject: clock: Fix spinning X-Git-Tag: otter-0.5.0~621 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a82f37fdb0c16f9830b11206cef9d4318e36e12b;p=otter.git clock: Fix spinning Signed-off-by: Ian Jackson --- diff --git a/src/clock.rs b/src/clock.rs index aa8faa2d..ce9a065f 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -297,8 +297,6 @@ impl ThreadState { #[throws(IE)] fn run(mut self) { loop { - // xxx this seems to spin - match self.next_wakeup { Some(wakeup) => { let timeout = wakeup - now()?; @@ -341,10 +339,11 @@ impl ThreadState { || internal_error_bydebug(&state) )?.expires - now; state.users[user].remaining = remaining; - Some(libc::timespec { + let pause: TimeSpec = libc::timespec { tv_sec: 0, tv_nsec: remaining.tv_nsec(), - }.into()) + }.into(); + Some(pause + now) } else { None };