[newlib-cygwin] Cygwin: timerfd: fix select always returning immediately

Corinna Vinschen corinna@sourceware.org
Sat Feb 23 22:07:00 GMT 2019


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

commit 0fb41d48aa3b0e8637a783961ffe4d67911fec50
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Sat Feb 23 23:02:44 2019 +0100

    Cygwin: timerfd: fix select always returning immediately
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/select.cc | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index d6757e4..5932586 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -1871,6 +1871,26 @@ fhandler_signalfd::select_except (select_stuff *stuff)
   return s;
 }
 
+static int
+peek_timerfd (select_record *me, bool)
+{
+  if (WaitForSingleObject (me->h, 0) == WAIT_OBJECT_0)
+    {
+      select_printf ("timerfd %d ready", me->fd);
+      me->read_ready = true;
+      return 1;
+    }
+  select_printf ("timerfd %d not ready", me->fd);
+  return 0;
+}
+
+static int
+verify_timerfd (select_record *me, fd_set *rfds, fd_set *wfds,
+		fd_set *efds)
+{
+  return peek_timerfd (me, true);
+}
+
 select_record *
 fhandler_timerfd::select_read (select_stuff *stuff)
 {
@@ -1878,11 +1898,12 @@ fhandler_timerfd::select_read (select_stuff *stuff)
   if (!s->startup)
     {
       s->startup = no_startup;
-      s->verify = verify_ok;
+      s->verify = verify_timerfd;
     }
   s->h = get_timerfd_handle ();
+  s->peek = peek_timerfd;
   s->read_selected = true;
-  s->read_ready = true;
+  s->read_ready = false;
   return s;
 }



More information about the Cygwin-cvs mailing list