[glib: 2/4] gmain: do not wakeup the wakeup registration




commit 17ac6642c78aed4fe3a7f7869877cec004aff394
Author: Marc-André Lureau <marcandre lureau redhat com>
Date:   Thu Jul 7 15:50:10 2022 +0400

    gmain: do not wakeup the wakeup registration
    
    Do not wakeup immediately for our own context wakeup poll registration.
    
    g_main_context_add_poll_unlocked() will call g_wakeup_signal() to wake
    up the loop waiting in poll(). Doing so during context creation will
    create an extra wakeup for the first poll().
    
    Skip the wakeup call if it is the wake_up_rec registration. No other
    sources/caller should ever reach that condition.
    
    Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>

 glib/gmain.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index a0ade8acbb..d6a67facb5 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -4653,7 +4653,8 @@ g_main_context_add_poll_unlocked (GMainContext *context,
   context->poll_changed = TRUE;
 
   /* Now wake up the main loop if it is waiting in the poll() */
-  g_wakeup_signal (context->wakeup);
+  if (fd != &context->wake_up_rec)
+    g_wakeup_signal (context->wakeup);
 }
 
 /**


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