From ceb0daa48bd6b5144873a4984572c2781fa4a7ac Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Wed, 4 Jan 2017 10:31:08 +0100 Subject: Do not sent user invisible mounts if not needed g_volume_monitor_get() might be really slow if there is too many mounts, because the list of the mounts is send over D-Bus. It can simply happen due to user invisible mounts, e.g. http. User invisible mounts are ignored by the volume monitor, so it is useless to send them over D-Bus. Improve the D-Bus API and don't send the user invisible mounts if it is not needed. https://bugzilla.gnome.org/show_bug.cgi?id=775600 --- client/gdaemonvolumemonitor.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'client') diff --git a/client/gdaemonvolumemonitor.c b/client/gdaemonvolumemonitor.c index b73453b2..dc1407d2 100644 --- a/client/gdaemonvolumemonitor.c +++ b/client/gdaemonvolumemonitor.c @@ -148,14 +148,11 @@ mount_added (GDaemonVolumeMonitor *daemon_monitor, GMountInfo *mount_info) return; } - if (mount_info->user_visible) - { - mount = g_daemon_mount_new (mount_info, G_VOLUME_MONITOR (daemon_monitor)); - daemon_monitor->mounts = g_list_prepend (daemon_monitor->mounts, mount); + mount = g_daemon_mount_new (mount_info, G_VOLUME_MONITOR (daemon_monitor)); + daemon_monitor->mounts = g_list_prepend (daemon_monitor->mounts, mount); - /* Ref for the signal emission, other ref is owned by volume monitor */ - g_object_ref (mount); - } + /* Ref for the signal emission, other ref is owned by volume monitor */ + g_object_ref (mount); G_UNLOCK (daemon_vm); @@ -177,8 +174,7 @@ mount_removed (GDaemonVolumeMonitor *daemon_monitor, GMountInfo *mount_info) mount = find_mount_by_mount_info (daemon_monitor, mount_info); if (!mount) { - if (mount_info->user_visible) - g_warning (G_STRLOC ": An unknown mount was removed!"); + g_warning (G_STRLOC ": An unknown mount was removed!"); G_UNLOCK (daemon_vm); return; @@ -203,7 +199,7 @@ g_daemon_volume_monitor_init (GDaemonVolumeMonitor *daemon_monitor) _the_daemon_volume_monitor = daemon_monitor; - daemon_monitor->mount_tracker = g_mount_tracker_new (_g_daemon_vfs_get_async_bus ()); + daemon_monitor->mount_tracker = g_mount_tracker_new (_g_daemon_vfs_get_async_bus (), TRUE); g_signal_connect_swapped (daemon_monitor->mount_tracker, "mounted", (GCallback) mount_added, daemon_monitor); @@ -215,12 +211,10 @@ g_daemon_volume_monitor_init (GDaemonVolumeMonitor *daemon_monitor) for (l = mounts; l != NULL; l = l->next) { info = l->data; - if (info->user_visible) - { - mount = g_daemon_mount_new (info, G_VOLUME_MONITOR (daemon_monitor)); - daemon_monitor->mounts = g_list_prepend (daemon_monitor->mounts, mount); - } - + + mount = g_daemon_mount_new (info, G_VOLUME_MONITOR (daemon_monitor)); + daemon_monitor->mounts = g_list_prepend (daemon_monitor->mounts, mount); + g_mount_info_unref (info); } -- cgit v1.2.1