dovecot: Fixes to handling inconsistent views after index reset.
dovecot at dovecot.org
dovecot at dovecot.org
Sat Nov 3 20:22:21 EET 2007
details: http://hg.dovecot.org/dovecot/rev/c5e4a7b75586
changeset: 6673:c5e4a7b75586
user: Timo Sirainen <tss at iki.fi>
date: Sat Nov 03 20:22:17 2007 +0200
description:
Fixes to handling inconsistent views after index reset.
diffstat:
2 files changed, 17 insertions(+), 4 deletions(-)
src/lib-index/mail-index-view-sync.c | 11 +++++++++--
src/lib-storage/index/index-sync.c | 10 ++++++++--
diffs (60 lines):
diff -r baf570ca608b -r c5e4a7b75586 src/lib-index/mail-index-view-sync.c
--- a/src/lib-index/mail-index-view-sync.c Sat Nov 03 18:40:40 2007 +0200
+++ b/src/lib-index/mail-index-view-sync.c Sat Nov 03 20:22:17 2007 +0200
@@ -293,10 +293,17 @@ int mail_index_view_sync_begin(struct ma
ctx->view = view;
ctx->flags = flags;
ctx->expunges = expunges;
- ctx->finish_min_msg_count =
+ ctx->finish_min_msg_count = reset ? 0 :
view->map->hdr.messages_count - expunge_count;
mail_index_sync_map_init(&ctx->sync_map_ctx, view,
MAIL_INDEX_SYNC_HANDLER_VIEW);
+
+ if (reset && view->map->hdr.messages_count > 0) {
+ view->inconsistent = TRUE;
+ mail_index_set_error(view->index,
+ "%s reset, view is now inconsistent",
+ view->index->filepath);
+ }
if (sync_expunges || !view_sync_have_expunges(view)) {
view->sync_new_map = view->index->map;
@@ -618,7 +625,7 @@ int mail_index_view_sync_commit(struct m
{
struct mail_index_view_sync_ctx *ctx = *_ctx;
struct mail_index_view *view = ctx->view;
- int ret = ctx->failed ? -1 : 0;
+ int ret = ctx->failed || view->inconsistent ? -1 : 0;
i_assert(view->syncing);
diff -r baf570ca608b -r c5e4a7b75586 src/lib-storage/index/index-sync.c
--- a/src/lib-storage/index/index-sync.c Sat Nov 03 18:40:40 2007 +0200
+++ b/src/lib-storage/index/index-sync.c Sat Nov 03 20:22:17 2007 +0200
@@ -261,8 +261,12 @@ index_mailbox_expunge_unseen_recent(stru
hdr = mail_index_get_header(ibox->view);
if (ctx->messages_count == 0)
uid = 0;
- else
+ else if (ctx->messages_count <= hdr->messages_count)
mail_index_lookup_uid(ibox->view, ctx->messages_count, &uid);
+ else {
+ i_assert(mail_index_view_is_inconsistent(ibox->view));
+ return;
+ }
for (seq = ctx->messages_count + 1; seq <= hdr->messages_count; seq++) {
start_uid = uid;
@@ -312,8 +316,10 @@ int index_mailbox_sync_deinit(struct mai
int ret = ctx->failed ? -1 : 0;
if (ctx->sync_ctx != NULL) {
- if (mail_index_view_sync_commit(&ctx->sync_ctx) < 0)
+ if (mail_index_view_sync_commit(&ctx->sync_ctx) < 0) {
+ mail_storage_set_index_error(ibox);
ret = -1;
+ }
}
index_mailbox_expunge_unseen_recent(ctx);
More information about the dovecot-cvs
mailing list