From 4c50dc94c38cca718a7dc8a4f1dd6f2e5b1c4cfb Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 22 Jan 2019 15:06:51 +0100 Subject: [PATCH] Cygwin: timerfd: another overrun computation fix and drop useless variable - When correcting the next expiration timestamp, the number of expirations gets computed correctly, just the expiration timestamp itself is then only incremented by a single interval, rather than the just computed expired intervals. Fix that. - drop the local clock variable in timerfd_tracker::create. It doesn't serve any purpose. Signed-off-by: Corinna Vinschen --- winsup/cygwin/timerfd.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/timerfd.cc b/winsup/cygwin/timerfd.cc index e865c0c15..87074fd6f 100644 --- a/winsup/cygwin/timerfd.cc +++ b/winsup/cygwin/timerfd.cc @@ -163,9 +163,9 @@ timerfd_tracker::thread_func () bigger than "now" and fix expiration count as required */ while (ts <= (now = get_clock_now ())) { - increment_expiration_count ((now - ts + get_interval () - 1) - / get_interval ()); - ts += get_interval (); + exp_cnt = (now - ts + get_interval () - 1) / get_interval (); + increment_expiration_count (exp_cnt); + ts += get_interval () * exp_cnt; } set_exp_ts (ts); /* NtSetTimer allows periods of up to 24 days only. If the time @@ -271,7 +271,6 @@ int timerfd_tracker::create (clockid_t clock_id) { int ret; - clk_t *clock; NTSTATUS status; OBJECT_ATTRIBUTES attr; @@ -281,8 +280,7 @@ timerfd_tracker::create (clockid_t clock_id) LARGE_INTEGER sectionsize = { QuadPart: PAGE_SIZE }; /* Valid clock? */ - clock = get_clock (clock_id); - if (!clock) + if (!get_clock (clock_id)) { ret = -EINVAL; goto err;