inotify polling in master branch

Vincent Lefevre vincent at vinc17.org
Sun Jun 10 08:33:15 UTC 2018


On 2018-06-09 08:04:21 +0800, Kevin J. McCarthy wrote:
> I've had it on my todo list, but hadn't had a chance to look into it
> yet.  Taking a quick peek, the mh_sync_mailbox() code touches the
> context->mtime value using maildir_update_mtime(), and even has a
> comment about a possible race condition.  I'm not sure what to do about
> it yet, but perhaps this is what you encountered?

I'm not sure I understand. If you mean that in some rare occasions,
new mail could fail to be detected, then this is a known issue I had
already seen and reported (bug 3475 in the old BTS), but I had found
that the race condition seemed to be here:

 The problem occurred once again! I've looked at the code in
 maildir_check_mailbox from mh.c and it seems incorrect:
 {{{
   /* determine which subdirectories need to be scanned */
   if (st_new.st_mtime > ctx->mtime)
     changed = 1;
   if (st_cur.st_mtime > data->mtime_cur)
     changed |= 2;

   if (!changed)
     return 0;                   /* nothing to do */

   /* update the modification times on the mailbox */
   data->mtime_cur = st_cur.st_mtime;
   ctx->mtime = st_new.st_mtime;
 }}}
 This seems to be subject to race condition, in particular if new mail
 arrives at about the same time the mailbox is synchronized (I think this
 is what happens in my case). I don't think it is possible to avoid a race
 condition when considering only the timestamp of the new subdirectory. But
 for instance, a full check (scan) of the new subdirectory could be done
 systematically several seconds after the latest change (due to
 synchronization or new mail). I don't think it is useful to do the same
 thing for the cur subdirectory.

But note that after some change and synchronizing the mailbox, the
new mail could be detected, IIRC.

Here, with inotify support enabled, this is different as new mail
is never detected. The problem disappeared when I recompiled with
--disable-filemonitor.

Now I'm thinking that there may be a more important new race condition
due to inotify because files could be looked as soon as they appear,
and if there is an mtime correction (which occurs here, AFAIK, as I'm
using unison to retrieve mail and synchronize between various copies
of my mailboxes), this might confuse Mutt.

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the Mutt-dev mailing list