dovecot-2.0: lib-storage: Avoid fsyncing subscriptions file when...

dovecot at dovecot.org dovecot at dovecot.org
Mon Sep 27 17:40:07 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/4959db811d29
changeset: 12186:4959db811d29
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Sep 27 15:40:02 2010 +0100
description:
lib-storage: Avoid fsyncing subscriptions file when it doesn't change or if mail_fsync=never.

diffstat:

 src/lib-storage/list/subscription-file.c |  18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diffs (51 lines):

diff -r a3c8026d0305 -r 4959db811d29 src/lib-storage/list/subscription-file.c
--- a/src/lib-storage/list/subscription-file.c	Mon Sep 27 13:45:24 2010 +0100
+++ b/src/lib-storage/list/subscription-file.c	Mon Sep 27 15:40:02 2010 +0100
@@ -95,7 +95,7 @@
 	int fd_in, fd_out;
 	mode_t mode;
 	gid_t gid;
-	bool found, failed = FALSE;
+	bool found, changed = FALSE, failed = FALSE;
 
 	if (strcasecmp(name, "INBOX") == 0)
 		name = "INBOX";
@@ -144,8 +144,10 @@
 				 &failed, FALSE)) != NULL) {
 		if (strcmp(line, name) == 0) {
 			found = TRUE;
-			if (!set)
+			if (!set) {
+				changed = TRUE;
 				continue;
+			}
 		}
 
 		if (o_stream_send_str(output, line) < 0 ||
@@ -163,18 +165,22 @@
 			subswrite_set_syscall_error(list, "write()", path);
 			failed = TRUE;
 		}
+		changed = TRUE;
 	}
 
-	if (!failed && fsync(fd_out) < 0) {
-		subswrite_set_syscall_error(list, "fsync()", path);
-		failed = TRUE;
+	if (changed && !failed &&
+	    list->mail_set->parsed_fsync_mode != FSYNC_MODE_NEVER) {
+		if (fsync(fd_out) < 0) {
+			subswrite_set_syscall_error(list, "fsync()", path);
+			failed = TRUE;
+		}
 	}
 
 	if (input != NULL)
 		i_stream_destroy(&input);
 	o_stream_destroy(&output);
 
-	if (failed || (set && found) || (!set && !found)) {
+	if (failed || !changed) {
 		if (file_dotlock_delete(&dotlock) < 0) {
 			subswrite_set_syscall_error(list,
 				"file_dotlock_delete()", path);


More information about the dovecot-cvs mailing list