From 5fbace55488af10cff74218954405e4c1d0c856b Mon Sep 17 00:00:00 2001 From: Richard Hult Date: Sun, 26 Jan 2003 00:06:30 +0000 Subject: 2003-01-26 Richard Hult * glib/dbus-gmain.c (dbus_connection_dispatch): Traverse a copy of the file descriptor list, since it can change under us. --- glib/dbus-gmain.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'glib/dbus-gmain.c') diff --git a/glib/dbus-gmain.c b/glib/dbus-gmain.c index 6697c125..5766139d 100644 --- a/glib/dbus-gmain.c +++ b/glib/dbus-gmain.c @@ -89,11 +89,13 @@ dbus_connection_dispatch (GSource *source, gpointer user_data) { DBusGSource *dbus_source = (DBusGSource *)source; - - GList *list; + GList *copy, *list; - list = dbus_source->poll_fds; + /* We need to traverse a copy of the list, since it can change in + dbus_connect_handle_watch. */ + copy = g_list_copy (dbus_source->poll_fds); + list = copy; while (list) { GPollFD *poll_fd = list->data; @@ -114,10 +116,12 @@ dbus_connection_dispatch (GSource *source, dbus_connection_handle_watch (dbus_source->connection, watch, condition); } - + list = list->next; } + g_list_free (copy); + /* Dispatch messages */ while (dbus_connection_dispatch_message (dbus_source->connection)); -- cgit