ev_stat inotify implementation might miss events

Marc Lehmann schmorp at schmorp.de
Tue Jan 26 16:23:24 CET 2010


On Tue, Jan 26, 2010 at 09:40:19AM +0100, Yoann Vandoorselaere <yoann.v at prelude-ids.com> wrote:
> As I understand it, inotify guarantee that you'll get an event for every
> changes on the file.

That is impossible unless you make everything synchronous, so inotify
cannot guarantee it.

> However, it might happen that Inotify merge event together, if the same
> event is received multiple time.

or throw an older one away,in any case, you will not get one event per
change.

> This is not a problem if there is no more event queued for the given wd;
> but in the other case, if there are multiple events queued, then the
> infy_cb loop is going to continue calling infy_wd() with the *old* watch
> descriptor. 

That doesn't matter, as we have the new watcher in place, so no events
will be lost (modulo kernel bugs).

i.e. even if there is a bug in inotify causing atcual events for the old
id, we will receive the same events for the new id (again, barring bugs in
the kernel).

> Then, infy_wd() won't be able to find the corresponding ev_stat
> structure since the watch descriptor used by Inotify has been
> reallocated in libev. This lead to some events being lost.

That would be two bugs in the kernel: a) sending events for removed
watchers and b) not sending events for existing watchers.

> > libev needs to rearm inotify after a change, as the event might have
> > changed the path.
> 
> Are you talking about file renaming/deletion?s

Yes.

> If you are, I might have some suggestion on other way to handle that.

Sure, I don't see any - afaics you have to change watchers. At best you
can make an optimisation for certain events, but changing is required in
general, as the path changes.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list