[glib] Stop checking for fork() across GMainContext



commit 7ab25865f229ad8d98a067b590319bfdd988e50e
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Oct 14 19:41:08 2011 -0400

    Stop checking for fork() across GMainContext
    
    01ed78d525cf2f8769022e27cc2573ec7ba123b3 introduced assertion checks for
    creating a main context, forking, and attempting to use the main context
    from the child side of the fork.
    
    Some code (such as gnome-keyring-daemon) daemonise after calling
    GMainContext.  That's probably still mostly safe since we still only
    have one side of the fork touching the context afterwards.
    
    This use case is still troubling, however, since if any worker threads
    have been created at the time of the fork(), we could end up in the
    classic situation of leaving some mutexes in a locked state when the
    other threads disappear from the copy of the image that the child gets.
    
    This will require some deeper thinking...

 glib/gmain.c |   14 --------------
 1 files changed, 0 insertions(+), 14 deletions(-)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index df87f90..6a7cfc0 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -378,7 +378,6 @@ static gboolean g_idle_dispatch    (GSource     *source,
 				    gpointer     user_data);
 
 static GMainContext *glib_worker_context;
-static gboolean      g_main_context_fork_detected;
 
 G_LOCK_DEFINE_STATIC (main_loop);
 static GMainContext *default_main_context;
@@ -500,14 +499,6 @@ g_main_context_unref (GMainContext *context)
   g_free (context);
 }
 
-#ifdef G_OS_UNIX
-static void
-g_main_context_forked (void)
-{
-  g_main_context_fork_detected = TRUE;
-}
-#endif
-
 /**
  * g_main_context_new:
  * 
@@ -528,10 +519,6 @@ g_main_context_new (void)
         _g_main_poll_debug = TRUE;
 #endif
 
-#ifdef G_OS_UNIX
-      pthread_atfork (NULL, NULL, g_main_context_forked);
-#endif
-
       g_once_init_leave (&initialised, TRUE);
     }
 
@@ -3000,7 +2987,6 @@ g_main_context_iterate (GMainContext *context,
   if (!block)
     timeout = 0;
   
-  g_assert (!g_main_context_fork_detected);
   g_main_context_poll (context, timeout, max_priority, fds, nfds);
   
   some_ready = g_main_context_check (context, max_priority, fds, nfds);



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