public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: posix timers: fix overrun computation
@ 2019-01-16 11:57 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2019-01-16 11:57 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=89a99d3b580083818fa8d4117fd4916bf8a8fe00
commit 89a99d3b580083818fa8d4117fd4916bf8a8fe00
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Wed Jan 16 00:11:03 2019 +0100
Cygwin: posix timers: fix overrun computation
- Drop initial overrun computation from timer_tracker::settimer.
It's performed in timer_tracker::thread_func anyway.
- Fix regression in returning correct overrun count narrowed down to
int from timer_getoverrun. This has been introduced by changing
overrun_count_curr to LONG64.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/timer.cc | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/winsup/cygwin/timer.cc b/winsup/cygwin/timer.cc
index 657407f..c429af6 100644
--- a/winsup/cygwin/timer.cc
+++ b/winsup/cygwin/timer.cc
@@ -369,22 +369,9 @@ timer_tracker::settime (int in_flags, const itimerspec *value, itimerspec *ovalu
else
{
interval_us = timespec_to_us (value->it_interval);
- if (in_flags & TIMER_ABSTIME)
- {
- int64_t now = get_clock (clock_id)->usecs ();
-
- sleepto_us = timespec_to_us (value->it_value);
- if (sleepto_us <= now)
- {
- int64_t ov_cnt = (now - sleepto_us + (interval_us + 1))
- / interval_us;
- InterlockedAdd64 (&overrun_count, ov_cnt);
- sleepto_us += ov_cnt * interval_us;
- }
- }
- else
- sleepto_us = get_clock (clock_id)->usecs ()
- + timespec_to_us (value->it_value);
+ sleepto_us = timespec_to_us (value->it_value);
+ if (!(in_flags & TIMER_ABSTIME))
+ sleepto_us += get_clock (clock_id)->usecs ();
it_interval = value->it_interval;
if (!hcancel)
hcancel = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
@@ -564,7 +551,11 @@ timer_getoverrun (timer_t timerid)
set_errno (EINVAL);
__leave;
}
- ret = tt->getoverrun ();
+ LONG64 ov_cnt = tt->getoverrun ();
+ if (ov_cnt > DELAYTIMER_MAX || ov_cnt < 0)
+ ret = DELAYTIMER_MAX;
+ else
+ ret = ov_cnt;
}
__except (EFAULT) {}
__endtry
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-01-16 11:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-16 11:57 [newlib-cygwin] Cygwin: posix timers: fix overrun computation Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).