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
This commit is contained in:
Philip Withnall 2017-11-24 20:02:43 +00:00
parent 9853842c53
commit 748bb24985

View File

@ -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)