]> granicus.if.org Git - neomutt/commitdiff
Fix MonitorContextDescriptor update on removal.
authorKevin McCarthy <kevin@8t8.us>
Wed, 27 Jun 2018 02:48:25 +0000 (19:48 -0700)
committerRichard Russon <rich@flatcap.org>
Mon, 3 Sep 2018 01:04:32 +0000 (02:04 +0100)
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.

maildir/mh.c
monitor.c

index 4ecf442b21a6bbcf2d35f1dc3fb14794bd30ce45..506f4e512266ca87cfb5a1f9f60d82f07f82d55c 100644 (file)
@@ -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;
index 620b5e5a718a98239979465879c449e26c78705c..f9ab4a994b2f88e9afc24cc6b64580ff3aecca1c 100644 (file)
--- 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;