GNOME Bugzilla – Bug 658491
new subscriptions can report old events from an existing directory watch
Last modified: 2018-05-24 13:20:27 UTC
I've been having some issues with file-change monitoring, where I hook up a GFileMonitor to a file just after having changed it on disk. This only occurs in the case where a second monitor exists on the directory in question. (In this case, left hanging around due to a possible bug in the GTK file-chooser). It appears that the GIO backend code has a bit of a race, in that it can queue up events for a directory - then process them at some later time (after my new subscription is added). The OLD events match against the new subscription, and are dispatched - despite the events predating the subscription. Should adding a new subscription force processing of any events up to that point (before adding the new subscription), or would this be something that could be handled by looking at the timestamp on the events?
Inotify events look like: struct inotify_event { int wd; /* Watch descriptor */ uint32_t mask; /* Mask of events */ uint32_t cookie; /* Unique cookie associating related events (for rename(2)) */ uint32_t len; /* Size of name field */ char name[]; /* Optional null-terminated name */ }; No timestamp here, so it seems that we have to read out all the current events when we add another subscription and save the timestamp so that we know not to send it to the new monitor when we later process it.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/446.