Mercurial > dovecot > core-2.2
changeset 19306:ca17b29b1720
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).
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 14 Oct 2015 17:34:23 +0300 |
parents | 06908dbcee62 |
children | 17aac21b303d |
files | src/doveadm/dsync/dsync-mailbox-tree-sync.c |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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)) ; }