Stop checking for fork() across GMainContext

01ed78d525 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...
This commit is contained in:
Ryan Lortie 2011-10-14 19:41:08 -04:00
parent 51773c6c64
commit 7ab25865f2

View File

@ -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);