[glib/glib-2-54] inotify: Don’t propagate unrecognised events to GLocalFileMonitor
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-54] inotify: Don’t propagate unrecognised events to GLocalFileMonitor
- Date: Tue, 28 Nov 2017 13:57:31 +0000 (UTC)
commit 3246f1df993dc34200f6a263ba3395e58b2866a4
Author: Philip Withnall <withnall endlessm com>
Date: Fri Nov 24 20:02:43 2017 +0000
inotify: Don’t propagate unrecognised events to GLocalFileMonitor
If we can’t convert the inotify event mask into a GFileMonitorEvent enum
value, don’t propagate it to GLocalFileMonitor, since it hits an
assertion failure in that case.
This should no longer be possible since the previous commit to ignore
IN_Q_OVERFLOW events, but we might as well change this just in case
other bugs crop up in event mask handling.
Signed-off-by: Philip Withnall <withnall endlessm com>
https://bugzilla.gnome.org/show_bug.cgi?id=776147
gio/inotify/inotify-helper.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/gio/inotify/inotify-helper.c b/gio/inotify/inotify-helper.c
index dce57e5..a307a88 100644
--- a/gio/inotify/inotify-helper.c
+++ b/gio/inotify/inotify-helper.c
@@ -156,9 +156,12 @@ ih_event_callback (ik_event_t *event,
gboolean file_event)
{
gboolean interesting;
+ GFileMonitorEvent event_flags;
g_assert (!file_event); /* XXX hardlink support */
+ event_flags = ih_mask_to_EventFlags (event->mask);
+
if (event->mask & IN_MOVE)
{
/* We either have a rename (in the same directory) or a move
@@ -187,17 +190,22 @@ ih_event_callback (ik_event_t *event,
else
other = NULL;
- /* this is either an incoming or outgoing move */
- interesting = g_file_monitor_source_handle_event (sub->user_data, ih_mask_to_EventFlags
(event->mask),
+ /* This is either an incoming or outgoing move. Since we checked the
+ * event->mask above, it should have converted to a #GFileMonitorEvent
+ * properly. If not, the assumption we have made about event->mask
+ * only ever having a single bit set (apart from IN_ISDIR) is false.
+ * The kernel documentation is lacking here. */
+ g_assert (event_flags != -1);
+ interesting = g_file_monitor_source_handle_event (sub->user_data, event_flags
event->name, NULL, other, event->timestamp);
if (other)
g_object_unref (other);
}
}
- else
+ else if (event_flags != -1)
/* unpaired event -- no 'other' field */
- interesting = g_file_monitor_source_handle_event (sub->user_data, ih_mask_to_EventFlags (event->mask),
+ interesting = g_file_monitor_source_handle_event (sub->user_data, event_flags
event->name, NULL, NULL, event->timestamp);
if (event->mask & IN_CREATE)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]