dovecot-2.2: dsync: If rename algorithm seems go to an infinite ...

dovecot at dovecot.org dovecot at dovecot.org
Wed Oct 14 14:36:04 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/ca17b29b1720
changeset: 19306:ca17b29b1720
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Oct 14 17:34:23 2015 +0300
description:
dsync: If rename algorithm seems go to an infinite loop, log an error and stop.
Ideally we would of course fix the algorithm (especially to not require this
kind of looping).

diffstat:

 src/doveadm/dsync/dsync-mailbox-tree-sync.c |  11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diffs (35 lines):

diff -r 06908dbcee62 -r ca17b29b1720 src/doveadm/dsync/dsync-mailbox-tree-sync.c
--- a/src/doveadm/dsync/dsync-mailbox-tree-sync.c	Wed Oct 14 17:28:11 2015 +0300
+++ b/src/doveadm/dsync/dsync-mailbox-tree-sync.c	Wed Oct 14 17:34:23 2015 +0300
@@ -15,6 +15,8 @@
 #define TEMP_SUFFIX_MAX_LEN (sizeof("temp-")-1 + 8)
 #define TEMP_SUFFIX_FORMAT "temp-%x"
 
+#define MAX_RENAMES 100
+
 struct dsync_mailbox_tree_bfs_iter {
 	struct dsync_mailbox_tree *tree;
 
@@ -1076,6 +1078,7 @@
 static void
 dsync_mailbox_tree_handle_renames(struct dsync_mailbox_tree_sync_ctx *ctx)
 {
+	unsigned int count = 0;
 	bool changed;
 
 	do {
@@ -1088,7 +1091,13 @@
 			i_debug("brain %c: -- Mailbox renamed, restart sync --",
 				(ctx->sync_flags & DSYNC_MAILBOX_TREES_SYNC_FLAG_MASTER_BRAIN) != 0 ? 'M' : 'S');
 		}
-	} while (changed);
+	} while (changed && ++count <= MAX_RENAMES);
+
+	if (changed) {
+		i_error("BUG: Mailbox renaming algorithm got into a potentially infinite loop, aborting");
+		ctx->brain->failed = TRUE;
+	}
+
 	while (sync_rename_temp_mailboxes(ctx, ctx->local_tree, &ctx->local_tree->root)) ;
 	while (sync_rename_temp_mailboxes(ctx, ctx->remote_tree, &ctx->remote_tree->root)) ;
 }


More information about the dovecot-cvs mailing list