Subject: bug#21435: 25.0.50; file-notify has problems after renames

From: Eli Zaretskii <[email-masked]>
Date: Tue, 08 Sep 2015 22:19:38 +0300

> From: Tassilo Horn <[email-masked]>
> Cc: [email-masked]
> Date: Tue, 08 Sep 2015 21:05:00 +0200
> 
> I stepped through inotify_callback in inotify.c which can read 64 byte
> from inotifyfd where the size of one inotify event is 32 and that
> produces 2 emacs events (although I cannot see which events are
> created).  The Locals GUD frame always shows just nil for the `event'
> local variable even after the assignments to it and I stepped into the
> then-branch of an `if (!NILP(event.arg))' which makes it pretty clear
> that it cannot be nil.  Why is that?

Could be some gud bug.  Do you see the same when you invoke GDB from
the shell?

> Then I turned to `file-notify-callback'.  That receives one `move-from'
> event and one `move-to' event which I figured out by adding a message.
> The problem is that as soon as I edebug the function, I can only see the
> first call for the `mode-from' event.  After stepping through it, I
> won't be put into the debugger for the second event as if it has been
> discarded in the meantime.  My handle function is also not run when
> edebugging.  Is that expected that when edebugging event handlers one
> might miss events?

I always use 'message' when debugging event-driven code.  I just don't
trust edebug enough in these cases.

> Anyway, eventually I found and fixed the culprit which simply was that
> the watch descriptors of the pending and the current event were compared
> with `eq' which is not valid because inotify descriptors are conses.
> I've changed the comparison to `equal' which fixes the double-reporting
> issue.

Thanks.  But meanwhile Michale explained that this behavior was on
purpose, due to a recent change.  Do you see 2 events only when a file
was moved to a different directory, or also when it is renamed in the
same directory?