New mail not detected in current Maildir folder

When a new mail message arrives in the current Maildir folder, it is not always detected. This bug has occurred at least since 2010 (bug 3475 in the old BTS), but this is much worse with the new inotify-based monitor code (at least for me, using unison to synchronize between mailboxes). After looking at debug messages with mutt -d5, the cause seems to be a race condition when new messages arrive during the parsing of the folder (after the opendir). This new monitor code makes it worse since parsing is likely to occur at the beginning of the changes, in particular when several messages are received at the same time.

The maildir_update_mtime code in mh.c shows that the mtime is updated from a stat that occurs in this function, i.e. after the parsing, while it should have occurred before the opendir. One solution (which should also work with NFS, even with the shift between the times of the client and the server) could be to force a rescan a few seconds after the latest mtime update (if it has changed).

Assignee Loading
Time tracking Loading