changeset 7543:8a4ac809d472 HEAD

dbox: fdatasync() when saving.
author Timo Sirainen <tss@iki.fi>
date Sun, 25 May 2008 02:58:42 +0300
parents cf924043234d
children 7512b6d8afe1
files src/lib-storage/index/dbox/dbox-save.c
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/dbox/dbox-save.c	Sun May 25 02:52:39 2008 +0300
+++ b/src/lib-storage/index/dbox/dbox-save.c	Sun May 25 02:58:42 2008 +0300
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "array.h"
+#include "fdatasync-path.h"
 #include "hex-dec.h"
 #include "str.h"
 #include "istream.h"
@@ -232,6 +233,12 @@
 		dbox_file_set_syscall_error(mail->file, "write");
 		return -1;
 	}
+	if (!mail->file->mbox->ibox.fsync_disable) {
+		if (fdatasync(mail->file->fd) < 0) {
+			dbox_file_set_syscall_error(mail->file, "fdatasync");
+			return -1;
+		}
+	}
 	return 0;
 }
 
@@ -452,6 +459,13 @@
 	ctx->ctx.transaction = NULL; /* transaction is already freed */
 
 	(void)dbox_sync_finish(&ctx->sync_ctx, TRUE);
+
+	if (!ctx->mbox->ibox.fsync_disable) {
+		if (fdatasync_path(ctx->mbox->path) < 0) {
+			i_error("fdatasync_path(%s) failed: %m",
+				ctx->mbox->path);
+		}
+	}
 	dbox_transaction_save_rollback(ctx);
 }