[glib] Do not use revents as not updated



commit 48ea710ee38c1b54e30e5df411d841c8974cce0d
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jul 16 21:07:27 2016 -0400

    Do not use revents as not updated
    
    revents is set in the same function after some lines. This check was
    using revents from previous loop. This had the problem of causing two
    poll execution for every changes to poll records.
    
    Note that is not possible to move the code after revents is updated
    as probably poll_changed is TRUE causing the function to exit.
    
    Adapted from a patch by Frediano Ziglio,
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761102

 glib/gmain.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index 3db6432..454f5bf 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -3695,10 +3695,17 @@ g_main_context_check (GMainContext *context,
 
   TRACE (GLIB_MAIN_CONTEXT_BEFORE_CHECK (context, max_priority, fds, n_fds));
 
-  if (context->wake_up_rec.revents)
+  for (i = 0; i < n_fds; i++)
     {
-      TRACE (GLIB_MAIN_CONTEXT_WAKEUP_ACKNOWLEDGE (context));
-      g_wakeup_acknowledge (context->wakeup);
+      if (fds[i].fd == context->wake_up_rec.fd)
+        {
+          if (fds[i].revents)
+            {
+              TRACE (GLIB_MAIN_CONTEXT_WAKEUP_ACKNOWLEDGE (context));
+              g_wakeup_acknowledge (context->wakeup);
+            }
+          break;
+        }
     }
 
   /* If the set of poll file descriptors changed, bail out


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]