[newlib-cygwin] Cygwin: timerfd: another overrun computation fix and drop useless variable

Corinna Vinschen corinna@sourceware.org
Tue Jan 22 14:46:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=4c50dc94c38cca718a7dc8a4f1dd6f2e5b1c4cfb

commit 4c50dc94c38cca718a7dc8a4f1dd6f2e5b1c4cfb
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Tue Jan 22 15:06:51 2019 +0100

    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>

Diff:
---
 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 e865c0c..87074fd 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;



More information about the Cygwin-cvs mailing list