dovecot-2.0: mdbox: Flush dbox file's input buffer after writing...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jun 15 17:08:22 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/26594f6d784a
changeset: 11551:26594f6d784a
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jun 15 15:08:19 2010 +0100
description:
mdbox: Flush dbox file's input buffer after writing to the file.

diffstat:

 src/lib-storage/index/dbox-multi/mdbox-save.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r d1f7b5e17252 -r 26594f6d784a src/lib-storage/index/dbox-multi/mdbox-save.c
--- a/src/lib-storage/index/dbox-multi/mdbox-save.c	Tue Jun 15 14:37:46 2010 +0100
+++ b/src/lib-storage/index/dbox-multi/mdbox-save.c	Tue Jun 15 15:08:19 2010 +0100
@@ -187,7 +187,7 @@
 static int mdbox_save_finish_write(struct mail_save_context *_ctx)
 {
 	struct mdbox_save_context *ctx = (struct mdbox_save_context *)_ctx;
-	struct dbox_save_mail *mails;
+	struct dbox_save_mail *mail;
 
 	ctx->ctx.finished = TRUE;
 	if (ctx->ctx.dbox_output == NULL)
@@ -197,14 +197,19 @@
 	index_mail_cache_parse_deinit(_ctx->dest_mail,
 				      _ctx->received_date, !ctx->ctx.failed);
 
-	mails = array_idx_modifiable(&ctx->mails, array_count(&ctx->mails) - 1);
+	mail = array_idx_modifiable(&ctx->mails, array_count(&ctx->mails) - 1);
 	if (!ctx->ctx.failed) T_BEGIN {
-		if (mdbox_save_mail_write_metadata(ctx, mails) < 0)
+		if (mdbox_save_mail_write_metadata(ctx, mail) < 0)
 			ctx->ctx.failed = TRUE;
 		else
 			mdbox_map_append_finish(ctx->append_ctx);
 	} T_END;
 
+	if (mail->file_append->file->input != NULL) {
+		/* if we try to read the saved mail before unlocking file,
+		   make sure the input stream doesn't have stale data */
+		i_stream_sync(mail->file_append->file->input);
+	}
 	i_stream_unref(&ctx->ctx.input);
 
 	if (ctx->ctx.failed) {


More information about the dovecot-cvs mailing list