gmain: move finalization of GSource outside of context lock
authorDan Winship <danw@gnome.org>
Sat, 6 Nov 2010 13:35:25 +0000 (09:35 -0400)
committerDan Winship <danw@gnome.org>
Fri, 26 Nov 2010 20:07:28 +0000 (15:07 -0500)
This avoids ugly deadlock situations such as in
https://bugzilla.gnome.org/show_bug.cgi?id=586432

https://bugzilla.gnome.org/show_bug.cgi?id=626702

https://bugzilla.gnome.org/show_bug.cgi?id=634239

glib/gmain.c

index b182c66..301adb0 100644 (file)
@@ -1520,7 +1520,13 @@ g_source_unref_internal (GSource      *source,
        g_source_list_remove (source, context);
 
       if (source->source_funcs->finalize)
-       source->source_funcs->finalize (source);
+       {
+         if (context)
+           UNLOCK_CONTEXT (context);
+         source->source_funcs->finalize (source);
+         if (context)
+           LOCK_CONTEXT (context);
+       }
 
       g_free (source->name);
       source->name = NULL;