- g_hash_table_iter_init (&iter, object->priv->map_name_to_iface);
- while (g_hash_table_iter_next (&iter, NULL, (gpointer) &interface_skeleton))
- {
- g_dbus_interface_skeleton_flush (interface_skeleton);
- }
+ g_mutex_lock (&object->priv->lock);
+ to_flush = g_hash_table_get_values (object->priv->map_name_to_iface);
+ g_list_foreach (to_flush, (GFunc) g_object_ref, NULL);
+ g_mutex_unlock (&object->priv->lock);
+
+ for (l = to_flush; l != NULL; l = l->next)
+ g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (l->data));
+
+ g_list_free_full (to_flush, g_object_unref);