Move mx_unlock_file and mutt_unblock_signals to mbox.c. These two
functions are coded defensively, so it's safe to call them even if the
mailbox was not locked or signals not blocked; and it allows to remove a
comparison to ctx->magic in mx.c
---
 mbox.c |  2 ++
 mx.c   | 17 +----------------
 2 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/mbox.c b/mbox.c
index 538c982..1b03ee0 100644
--- a/mbox.c
+++ b/mbox.c
@@ -465,6 +465,8 @@ static int mbox_open_mailbox_append (CONTEXT *ctx, int 
flags)
 
 static int mbox_close_mailbox (CONTEXT *ctx)
 {
+  mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
+  mutt_unblock_signals ();
   return 0;
 }
 
diff --git a/mx.c b/mx.c
index 8d6e1dc..1977ec7 100644
--- a/mx.c
+++ b/mx.c
@@ -514,17 +514,6 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int flags)
   return ctx->mx_ops->open_append (ctx, flags);
 }
 
-/* close a mailbox opened in write-mode */
-static int mx_close_mailbox_append (CONTEXT **pctx)
-{
-  CONTEXT *ctx = *pctx;
-
-  mx_unlock_file (ctx->path, fileno (ctx->fp), 1);
-  mutt_unblock_signals ();
-  mx_fastclose_mailbox (pctx);
-  return 0;
-}
-
 /*
  * open a mailbox and parse it
  *
@@ -805,11 +794,7 @@ int mx_close_mailbox (CONTEXT **pctx, int *index_hint)
 
   if (ctx->append)
   {
-    /* mailbox was opened in write-mode */
-    if (ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF)
-      mx_close_mailbox_append (pctx);
-    else
-      mx_fastclose_mailbox (pctx);
+    mx_fastclose_mailbox (pctx);
     return 0;
   }
 
-- 
2.9.3

Reply via email to