[glib/gmain: 4/5] Remove non-threaded GMainLoop case



commit 0f20e2ebb73ccf594944b30271694f9ba14eb46f
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Jul 27 23:41:46 2011 -0400

    Remove non-threaded GMainLoop case
    
    Remove the broken optimisations for running GMainLoop without a wakeup
    handle for non-threaded environments.  This never worked, because
    mainloop wakeups can occur from within signal handlers (for SIGCHLD).
    
    This properly fixes a longstanding bug where SIGCHLD was sometimes
    missed in gtester, causing hangs.

 glib/gmain.c   |   41 +++++------------------------------------
 glib/gthread.c |    1 -
 2 files changed, 5 insertions(+), 37 deletions(-)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index a6c7f56..2ed9195 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -334,7 +334,6 @@ static gboolean g_idle_dispatch    (GSource     *source,
 
 G_LOCK_DEFINE_STATIC (main_loop);
 static GMainContext *default_main_context;
-static GSList *main_contexts_without_pipe = NULL;
 
 GSourceFuncs g_timeout_funcs =
 {
@@ -409,13 +408,8 @@ g_main_context_unref (GMainContext *context)
   g_free (context->cached_poll_array);
 
   poll_rec_list_free (context, context->poll_records);
-  
-  if (g_thread_supported())
-    g_wakeup_free (context->wakeup);
 
-  else
-    main_contexts_without_pipe = g_slist_remove (main_contexts_without_pipe, 
-						 context);
+  g_wakeup_free (context->wakeup);
 
   if (context->cond != NULL)
     g_cond_free (context->cond);
@@ -423,29 +417,6 @@ g_main_context_unref (GMainContext *context)
   g_free (context);
 }
 
-static void
-g_main_context_init_pipe (GMainContext *context)
-{
-  context->wakeup = g_wakeup_new ();
-  g_wakeup_get_pollfd (context->wakeup, &context->wake_up_rec);
-  g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
-}
-
-void
-_g_main_thread_init (void)
-{
-  GSList *curr;
-  
-  curr = main_contexts_without_pipe;
-  while (curr)
-    {
-      g_main_context_init_pipe ((GMainContext *)curr->data);
-      curr = curr->next;
-    }
-  g_slist_free (main_contexts_without_pipe);
-  main_contexts_without_pipe = NULL;  
-}
-
 /**
  * g_main_context_new:
  * 
@@ -491,12 +462,10 @@ g_main_context_new (void)
   
   context->time_is_fresh = FALSE;
   context->real_time_is_fresh = FALSE;
-  
-  if (g_thread_supported ())
-    g_main_context_init_pipe (context);
-  else
-    main_contexts_without_pipe = g_slist_prepend (main_contexts_without_pipe, 
-						  context);
+
+  context->wakeup = g_wakeup_new ();
+  g_wakeup_get_pollfd (context->wakeup, &context->wake_up_rec);
+  g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
 
 #ifdef G_MAIN_POLL_DEBUG
   if (_g_main_poll_debug)
diff --git a/glib/gthread.c b/glib/gthread.c
index 58d76c7..055e92d 100644
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@ -955,7 +955,6 @@ g_thread_init_glib (void)
   /* we may run full-fledged initializers from here */
   _g_convert_thread_init ();
   _g_rand_thread_init ();
-  _g_main_thread_init ();
   _g_utils_thread_init ();
   _g_futex_thread_init ();
 #ifdef G_OS_WIN32



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