dovecot-2.1: lib-index: Make sure we never go to infinite loop i...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Nov 23 19:10:49 EET 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/b9c4a7e4a27f
changeset: 13752:b9c4a7e4a27f
user: Timo Sirainen <tss at iki.fi>
date: Wed Nov 23 19:10:34 2011 +0200
description:
lib-index: Make sure we never go to infinite loop if fsck can't fix syncing problem.
diffstat:
src/lib-index/mail-index-sync.c | 41 ++++++++++++++++++++++++++++++++---------
1 files changed, 32 insertions(+), 9 deletions(-)
diffs (72 lines):
diff -r db51a627d726 -r b9c4a7e4a27f src/lib-index/mail-index-sync.c
--- a/src/lib-index/mail-index-sync.c Wed Nov 23 19:04:15 2011 +0200
+++ b/src/lib-index/mail-index-sync.c Wed Nov 23 19:10:34 2011 +0200
@@ -421,12 +421,13 @@
return 1;
}
-int mail_index_sync_begin_to(struct mail_index *index,
- struct mail_index_sync_ctx **ctx_r,
- struct mail_index_view **view_r,
- struct mail_index_transaction **trans_r,
- uint32_t log_file_seq, uoff_t log_file_offset,
- enum mail_index_sync_flags flags)
+static int
+mail_index_sync_begin_to2(struct mail_index *index,
+ struct mail_index_sync_ctx **ctx_r,
+ struct mail_index_view **view_r,
+ struct mail_index_transaction **trans_r,
+ uint32_t log_file_seq, uoff_t log_file_offset,
+ enum mail_index_sync_flags flags, bool *retry_r)
{
const struct mail_index_header *hdr;
struct mail_index_sync_ctx *ctx;
@@ -436,6 +437,8 @@
i_assert(!index->syncing);
+ *retry_r = FALSE;
+
if (index->map != NULL &&
(index->map->hdr.flags & MAIL_INDEX_HDR_FLAG_CORRUPTED) != 0) {
/* index is corrupted and need to be reopened */
@@ -481,9 +484,8 @@
to skip over it. fix the problem with fsck and try again. */
mail_index_fsck_locked(index);
mail_index_sync_rollback(&ctx);
- return mail_index_sync_begin_to(index, ctx_r, view_r, trans_r,
- log_file_seq, log_file_offset,
- flags);
+ *retry_r = TRUE;
+ return 0;
}
/* we need to have all the transactions sorted to optimize
@@ -513,6 +515,27 @@
return 1;
}
+int mail_index_sync_begin_to(struct mail_index *index,
+ struct mail_index_sync_ctx **ctx_r,
+ struct mail_index_view **view_r,
+ struct mail_index_transaction **trans_r,
+ uint32_t log_file_seq, uoff_t log_file_offset,
+ enum mail_index_sync_flags flags)
+{
+ bool retry;
+ int ret;
+
+ ret = mail_index_sync_begin_to2(index, ctx_r, view_r, trans_r,
+ log_file_seq, log_file_offset,
+ flags, &retry);
+ if (retry) {
+ ret = mail_index_sync_begin_to2(index, ctx_r, view_r, trans_r,
+ log_file_seq, log_file_offset,
+ flags, &retry);
+ }
+ return ret;
+}
+
bool mail_index_sync_has_expunges(struct mail_index_sync_ctx *ctx)
{
return array_is_created(&ctx->sync_trans->expunges) &&
More information about the dovecot-cvs
mailing list