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>
This commit is contained in:
parent
5b147c76d2
commit
89a99d3b58
|
@ -369,22 +369,9 @@ timer_tracker::settime (int in_flags, const itimerspec *value, itimerspec *ovalu
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
interval_us = timespec_to_us (value->it_interval);
|
interval_us = timespec_to_us (value->it_interval);
|
||||||
if (in_flags & TIMER_ABSTIME)
|
sleepto_us = timespec_to_us (value->it_value);
|
||||||
{
|
if (!(in_flags & TIMER_ABSTIME))
|
||||||
int64_t now = get_clock (clock_id)->usecs ();
|
sleepto_us += 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);
|
|
||||||
it_interval = value->it_interval;
|
it_interval = value->it_interval;
|
||||||
if (!hcancel)
|
if (!hcancel)
|
||||||
hcancel = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
|
hcancel = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
|
||||||
|
@ -564,7 +551,11 @@ timer_getoverrun (timer_t timerid)
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
__leave;
|
__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) {}
|
__except (EFAULT) {}
|
||||||
__endtry
|
__endtry
|
||||||
|
|
Loading…
Reference in New Issue