changeset: 6745:3834da0c024e
user: Kevin McCarthy <[email protected]>
date: Sun Jul 31 18:42:07 2016 -0700
link: http://dev.mutt.org/hg/mutt/rev/3834da0c024e
Move fflush and fsync to the mbox and mmdf commit_msg functions.
The case statement in mx_commit_message() was previously distributed
to the various ops->commit_msg() handlers, but the fflush and fsync were
not.
diffs (67 lines):
diff -r 27b77b5c97cf -r 3834da0c024e mbox.c
--- a/mbox.c Sat Jul 30 11:11:07 2016 -0700
+++ b/mbox.c Sun Jul 31 18:42:07 2016 -0700
@@ -463,20 +463,30 @@
static int mbox_commit_message (CONTEXT *ctx, MESSAGE *msg)
{
- int r = fputc ('\n', msg->fp);
+ if (fputc ('\n', msg->fp) == EOF)
+ return -1;
- if (r == EOF)
+ if ((fflush (msg->fp) == EOF) ||
+ (fsync (fileno (msg->fp)) == -1))
+ {
+ mutt_perror _("Can't write message");
return -1;
+ }
return 0;
}
static int mmdf_commit_message (CONTEXT *ctx, MESSAGE *msg)
{
- int r = fputs (MMDF_SEP, msg->fp);
+ if (fputs (MMDF_SEP, msg->fp) == EOF)
+ return -1;
- if (r == EOF)
+ if ((fflush (msg->fp) == EOF) ||
+ (fsync (fileno (msg->fp)) == -1))
+ {
+ mutt_perror _("Can't write message");
return -1;
+ }
return 0;
}
diff -r 27b77b5c97cf -r 3834da0c024e mx.c
--- a/mx.c Sat Jul 30 11:11:07 2016 -0700
+++ b/mx.c Sun Jul 31 18:42:07 2016 -0700
@@ -1423,7 +1423,6 @@
int mx_commit_message (MESSAGE *msg, CONTEXT *ctx)
{
struct mx_ops *ops = mx_get_ops (ctx->magic);
- int r = 0;
if (!ops || !ops->commit_msg)
return -1;
@@ -1435,16 +1434,7 @@
return -1;
}
- r = ops->commit_msg (ctx, msg);
-
- if (r == 0 && (ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF)
- && (fflush (msg->fp) == EOF || fsync (fileno (msg->fp)) == -1))
- {
- mutt_perror _("Can't write message");
- r = -1;
- }
-
- return r;
+ return ops->commit_msg (ctx, msg);
}
/* close a pointer to a message */