[glib] gunixmounts: Skip accumulated events from file monitor
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gunixmounts: Skip accumulated events from file monitor
- Date: Tue, 30 Jan 2018 14:47:11 +0000 (UTC)
commit 7e0d42e3dc7f64a11afcf124d635bf4ca435abd6
Author: Ondrej Holy <oholy redhat com>
Date: Mon Jan 15 17:56:26 2018 +0100
gunixmounts: Skip accumulated events from file monitor
Skip accumulated events from file monitor which we are not able to handle
in a real time instead of emitting mounts_changed signal several times.
This should behave equally to GIOChannel based monitoring. See Bug 792235.
https://bugzilla.gnome.org/show_bug.cgi?id=793006
gio/gunixmounts.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
index fc37129..add8e3f 100644
--- a/gio/gunixmounts.c
+++ b/gio/gunixmounts.c
@@ -1656,6 +1656,7 @@ static GFileMonitor *fstab_monitor;
static GFileMonitor *mtab_monitor;
static GSource *proc_mounts_watch_source;
static GList *mount_poller_mounts;
+static guint mtab_file_changed_id;
static gboolean
proc_mounts_watch_is_running (void)
@@ -1679,6 +1680,15 @@ fstab_file_changed (GFileMonitor *monitor,
g_context_specific_group_emit (&mount_monitor_group, signals[MOUNTPOINTS_CHANGED]);
}
+static gboolean
+mtab_file_changed_cb (gpointer user_data)
+{
+ mtab_file_changed_id = 0;
+ g_context_specific_group_emit (&mount_monitor_group, signals[MOUNTS_CHANGED]);
+
+ return G_SOURCE_REMOVE;
+}
+
static void
mtab_file_changed (GFileMonitor *monitor,
GFile *file,
@@ -1691,7 +1701,14 @@ mtab_file_changed (GFileMonitor *monitor,
event_type != G_FILE_MONITOR_EVENT_DELETED)
return;
- g_context_specific_group_emit (&mount_monitor_group, signals[MOUNTS_CHANGED]);
+ /* Skip accumulated events from file monitor which we are not able to handle
+ * in a real time instead of emitting mounts_changed signal several times.
+ * This should behave equally to GIOChannel based monitoring. See Bug 792235.
+ */
+ if (mtab_file_changed_id > 0)
+ return;
+
+ mtab_file_changed_id = g_idle_add (mtab_file_changed_cb, NULL);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]