summaryrefslogtreecommitdiffstats
path: root/mbox.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2016-07-31 18:42:07 -0700
committerKevin McCarthy <kevin@8t8.us>2016-07-31 18:42:07 -0700
commit4f33c66c210c5b8c73e095c8ff2a392ddae210f9 (patch)
tree63c0309792186c6330bf311d6e8ba3e7d48eb814 /mbox.c
parentc8c9bbd1141da97e91317acbca570fde8e4598c1 (diff)
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.
Diffstat (limited to 'mbox.c')
-rw-r--r--mbox.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/mbox.c b/mbox.c
index 36dd81e7..1aabe9e5 100644
--- a/mbox.c
+++ b/mbox.c
@@ -463,20 +463,30 @@ static int mbox_close_message (CONTEXT *ctx, MESSAGE *msg)
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;
}