From: Kevin McCarthy Date: Wed, 27 Jun 2018 02:48:25 +0000 (-0700) Subject: Fix MonitorContextDescriptor update on removal. X-Git-Tag: 2019-10-25~668^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a865b2e13c519548ee2d2768b89e051041b90cdf;p=neomutt Fix MonitorContextDescriptor update on removal. Reset the context descriptor before checking for the monitor being shared by another mailbox. Technically, it would be set properly during the next add, but it shouldn't be left incorrect. --- diff --git a/maildir/mh.c b/maildir/mh.c index 4ecf442b2..506f4e512 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -2351,7 +2351,7 @@ static int maildir_mbox_check(struct Context *ctx, int *index_hint) if (!changed) return 0; /* nothing to do */ - /* Update the modification times on the mailbox. + /* Update the modification times on the mailbox. * * The monitor code notices changes in the open mailbox too quickly. * In practice, this sometimes leads to all the new messages not being @@ -2363,8 +2363,8 @@ static int maildir_mbox_check(struct Context *ctx, int *index_hint) else #endif { - mutt_get_stat_timespec (&data->mtime_cur, &st_cur, MUTT_STAT_MTIME); - mutt_get_stat_timespec (&ctx->mtime, &st_new, MUTT_STAT_MTIME); + mutt_get_stat_timespec(&data->mtime_cur, &st_cur, MUTT_STAT_MTIME); + mutt_get_stat_timespec(&ctx->mtime, &st_new, MUTT_STAT_MTIME); } /* do a fast scan of just the filenames in @@ -2531,20 +2531,20 @@ static int mh_mbox_check(struct Context *ctx, int *index_hint) if (!modified) return 0; - /* Update the modification times on the mailbox. - * - * The monitor code notices changes in the open mailbox too quickly. - * In practice, this sometimes leads to all the new messages not being - * noticed during the SAME group of mtime stat updates. To work around - * the problem, don't update the stat times for a monitor caused check. */ + /* Update the modification times on the mailbox. + * + * The monitor code notices changes in the open mailbox too quickly. + * In practice, this sometimes leads to all the new messages not being + * noticed during the SAME group of mtime stat updates. To work around + * the problem, don't update the stat times for a monitor caused check. */ #ifdef USE_INOTIFY if (MonitorContextChanged) MonitorContextChanged = 0; else #endif { - mutt_get_stat_timespec (&data->mtime_cur, &st_cur, MUTT_STAT_MTIME); - mutt_get_stat_timespec (&ctx->mtime, &st, MUTT_STAT_MTIME); + mutt_get_stat_timespec(&data->mtime_cur, &st_cur, MUTT_STAT_MTIME); + mutt_get_stat_timespec(&ctx->mtime, &st, MUTT_STAT_MTIME); } md = NULL; diff --git a/monitor.c b/monitor.c index 620b5e5a7..f9ab4a994 100644 --- a/monitor.c +++ b/monitor.c @@ -189,7 +189,7 @@ static int monitor_handle_ignore(int desc) if (iter->magic == MUTT_MH && stat(iter->mh_backup_path, &sb) == 0) { if ((new_desc = inotify_add_watch(INotifyFd, iter->mh_backup_path, - INOTIFY_MASK_FILE)) == -1) + INOTIFY_MASK_FILE)) == -1) { mutt_debug(2, "inotify_add_watch failed for '%s', errno=%d %s\n", iter->mh_backup_path, errno, strerror(errno)); @@ -429,6 +429,9 @@ int mutt_monitor_remove(struct Mailbox *mailbox) if (monitor_resolve(&info, mailbox) != RESOLVERES_OK_EXISTING) return 2; + if (!mailbox && (MonitorContextDescriptor == info.monitor->desc)) + MonitorContextDescriptor = -1; + if (Context) { if (mailbox) @@ -448,9 +451,6 @@ int mutt_monitor_remove(struct Mailbox *mailbox) mutt_debug(3, "inotify_rm_watch for '%s' descriptor=%d\n", info.path, info.monitor->desc); - if (!mailbox && (MonitorContextDescriptor == info.monitor->desc)) - MonitorContextDescriptor = -1; - monitor_delete(info.monitor); monitor_check_free(); return 0;