dovecot-1.1: mbox_lazy_writes: If errors are noticed in mbox, wr...

dovecot at dovecot.org dovecot at dovecot.org
Sun May 4 19:19:27 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/591145eaaf87
changeset: 7483:591145eaaf87
user:      Timo Sirainen <tss at iki.fi>
date:      Sun May 04 19:19:23 2008 +0300
description:
mbox_lazy_writes: If errors are noticed in mbox, write changes to fix them
immediately to avoid constant errors in logs.

diffstat:

2 files changed, 17 insertions(+), 5 deletions(-)
src/lib-storage/index/mbox/mbox-sync-private.h |    1 +
src/lib-storage/index/mbox/mbox-sync.c         |   21 ++++++++++++++++-----

diffs (61 lines):

diff -r 955ae7b7ad1a -r 591145eaaf87 src/lib-storage/index/mbox/mbox-sync-private.h
--- a/src/lib-storage/index/mbox/mbox-sync-private.h	Sun May 04 18:19:57 2008 +0300
+++ b/src/lib-storage/index/mbox/mbox-sync-private.h	Sun May 04 19:19:23 2008 +0300
@@ -143,6 +143,7 @@ struct mbox_sync_context {
 	unsigned int moved_offsets:1;
 	unsigned int ext_modified:1;
 	unsigned int index_reset:1;
+	unsigned int errors:1;
 };
 
 int mbox_sync(struct mbox_mailbox *mbox, enum mbox_sync_flags flags);
diff -r 955ae7b7ad1a -r 591145eaaf87 src/lib-storage/index/mbox/mbox-sync.c
--- a/src/lib-storage/index/mbox/mbox-sync.c	Sun May 04 18:19:57 2008 +0300
+++ b/src/lib-storage/index/mbox/mbox-sync.c	Sun May 04 19:19:23 2008 +0300
@@ -68,6 +68,7 @@ void mbox_sync_set_critical(struct mbox_
 {
 	va_list va;
 
+	sync_ctx->errors = TRUE;
 	if (sync_ctx->ext_modified) {
 		mail_storage_set_critical(&sync_ctx->mbox->storage->storage,
 			"mbox file %s was modified while we were syncing, "
@@ -1455,6 +1456,7 @@ static void mbox_sync_restart(struct mbo
 
 	sync_ctx->dest_first_mail = TRUE;
 	sync_ctx->ext_modified = FALSE;
+	sync_ctx->errors = FALSE;
 }
 
 static int mbox_sync_do(struct mbox_sync_context *sync_ctx,
@@ -1501,16 +1503,25 @@ static int mbox_sync_do(struct mbox_sync
 	}
 
 	mbox_sync_restart(sync_ctx);
-	for (i = 0; i < 3; i++) {
+	for (i = 0;;) {
 		ret = mbox_sync_loop(sync_ctx, &mail_ctx, partial);
-		if (ret > 0)
+		if (ret > 0 && !sync_ctx->errors)
 			break;
 		if (ret < 0)
 			return -1;
 
-		/* partial syncing didn't work, do it again. we get here
-		   also if we ran out of UIDs. */
-		i_assert(sync_ctx->mbox->mbox_sync_dirty);
+		/* a) partial sync didn't work
+		   b) we ran out of UIDs
+		   c) syncing had errors */
+		if (sync_ctx->delay_writes && !sync_ctx->mbox->mbox_readonly &&
+		    (sync_ctx->errors || sync_ctx->renumber_uids)) {
+			/* fixing a broken mbox state, be sure to write
+			   the changes. */
+			sync_ctx->delay_writes = FALSE;
+		}
+		if (++i == 3)
+			break;
+
 		mbox_sync_restart(sync_ctx);
 		partial = FALSE;
 	}


More information about the dovecot-cvs mailing list