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 <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2019-01-22 15:06:51 +01:00
parent a75bd958b4
commit 4c50dc94c3
1 changed files with 4 additions and 6 deletions

View File

@ -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;