Index: ChangeLog =================================================================== RCS file: /cvs/dbus/dbus/ChangeLog,v retrieving revision 1.750 diff -u -p -r1.750 ChangeLog --- ChangeLog 31 Mar 2005 02:24:11 -0000 1.750 +++ ChangeLog 6 Apr 2005 00:44:40 -0000 @@ -1,3 +1,8 @@ +2005-04-05 David Zeuthen + + * glib/dbus-gmain.c (connection_setup_free): Fix a deadlock when + freeing IO and Timeout sources + 2005-03-30 Havoc Pennington * configure.in: change check to gtk 2.4 Index: glib/dbus-gmain.c =================================================================== RCS file: /cvs/dbus/dbus/glib/dbus-gmain.c,v retrieving revision 1.37 diff -u -p -r1.37 dbus-gmain.c --- glib/dbus-gmain.c 30 Jan 2005 23:06:32 -0000 1.37 +++ glib/dbus-gmain.c 6 Apr 2005 00:44:40 -0000 @@ -399,11 +399,26 @@ connection_setup_remove_timeout (Connect static void connection_setup_free (ConnectionSetup *cs) { - while (cs->ios) - io_handler_destroy_source (cs->ios->data); + GSList *i; - while (cs->timeouts) - timeout_handler_destroy_source (cs->timeouts->data); + /* the mainloop might be holding references to these sources so we'll deadlock + * if we try to wait for them to finalize; since the connection is going away + * remove our callbacks and simply unref them - when the mainloop gives up + * references the sources will be finalized + */ + for (i = cs->ios; i != NULL; i = g_slist_next (i)) + { + g_source_set_callback (i->data, NULL, NULL, NULL); + io_handler_destroy_source (i->data); + } + g_slist_free (cs->ios); + + for (i = cs->timeouts; i != NULL; i = g_slist_next (i)) + { + g_source_set_callback (i->data, NULL, NULL, NULL); + timeout_handler_destroy_source (i->data); + } + g_slist_free (cs->timeouts); if (cs->message_queue_source) {