dovecot-1.2: mail_index_view_sync_begin() now delays its failure...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Jun 17 12:36:48 EEST 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/3882c6cbfa99
changeset: 7872:3882c6cbfa99
user: Timo Sirainen <tss at iki.fi>
date: Tue Jun 17 09:56:28 2008 +0300
description:
mail_index_view_sync_begin() now delays its failures to _commit().
diffstat:
3 files changed, 29 insertions(+), 28 deletions(-)
src/lib-index/mail-index-view-sync.c | 43 +++++++++++++++++++---------------
src/lib-index/mail-index.h | 6 ++--
src/lib-storage/index/index-sync.c | 8 ------
diffs (135 lines):
diff -r 6718f97ed2c3 -r 3882c6cbfa99 src/lib-index/mail-index-view-sync.c
--- a/src/lib-index/mail-index-view-sync.c Tue Jun 17 08:14:53 2008 +0300
+++ b/src/lib-index/mail-index-view-sync.c Tue Jun 17 09:56:28 2008 +0300
@@ -264,9 +264,9 @@ static bool view_sync_have_expunges(stru
return ret < 0 || have_expunges;
}
-int mail_index_view_sync_begin(struct mail_index_view *view,
- enum mail_index_view_sync_flags flags,
- struct mail_index_view_sync_ctx **ctx_r)
+struct mail_index_view_sync_ctx *
+mail_index_view_sync_begin(struct mail_index_view *view,
+ enum mail_index_view_sync_flags flags)
{
struct mail_index_view_sync_ctx *ctx;
struct mail_index_map *map;
@@ -276,6 +276,12 @@ int mail_index_view_sync_begin(struct ma
i_assert(!view->syncing);
i_assert(view->transactions == 0);
+
+ view->syncing = TRUE;
+
+ ctx = i_new(struct mail_index_view_sync_ctx, 1);
+ ctx->view = view;
+ ctx->flags = flags;
quick_sync = (flags & MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT) != 0;
if (mail_index_view_is_inconsistent(view)) {
@@ -283,7 +289,8 @@ int mail_index_view_sync_begin(struct ma
mail_index_set_error(view->index,
"%s view is inconsistent",
view->index->filepath);
- return -1;
+ ctx->failed = TRUE;
+ return ctx;
}
view->inconsistent = FALSE;
}
@@ -294,20 +301,21 @@ int mail_index_view_sync_begin(struct ma
i_array_init(&expunges, 1);
} else if (sync_expunges) {
/* get list of all expunges first */
- if (view_sync_get_expunges(view, &expunges, &expunge_count) < 0)
- return -1;
+ if (view_sync_get_expunges(view, &expunges,
+ &expunge_count) < 0) {
+ ctx->failed = TRUE;
+ return ctx;
+ }
}
if (view_sync_set_log_view_range(view, sync_expunges, quick_sync,
&reset) < 0) {
if (array_is_created(&expunges))
array_free(&expunges);
- return -1;
- }
-
- ctx = i_new(struct mail_index_view_sync_ctx, 1);
- ctx->view = view;
- ctx->flags = flags;
+ ctx->failed = TRUE;
+ return ctx;
+ }
+
ctx->expunges = expunges;
ctx->finish_min_msg_count = reset || quick_sync ? 0 :
view->map->hdr.messages_count - expunge_count;
@@ -366,10 +374,7 @@ int mail_index_view_sync_begin(struct ma
/* Syncing the view invalidates all previous looked up records.
Unreference the mappings this view keeps because of them. */
mail_index_view_unref_maps(view);
- view->syncing = TRUE;
-
- *ctx_r = ctx;
- return 0;
+ return ctx;
}
static bool
@@ -651,7 +656,8 @@ int mail_index_view_sync_commit(struct m
view->inconsistent = TRUE;
ret = -1;
}
- mail_index_modseq_sync_end(&ctx->sync_map_ctx.modseq_ctx);
+ if (ctx->sync_map_ctx.view != NULL)
+ mail_index_modseq_sync_end(&ctx->sync_map_ctx.modseq_ctx);
if (ctx->sync_new_map != NULL) {
mail_index_unmap(&view->map);
@@ -673,7 +679,8 @@ int mail_index_view_sync_commit(struct m
view->map->hdr.log_file_tail_offset = 0;
}
- mail_index_sync_map_deinit(&ctx->sync_map_ctx);
+ if (ctx->sync_map_ctx.view != NULL)
+ mail_index_sync_map_deinit(&ctx->sync_map_ctx);
mail_index_view_sync_clean_log_syncs(ctx->view);
#ifdef DEBUG
diff -r 6718f97ed2c3 -r 3882c6cbfa99 src/lib-index/mail-index.h
--- a/src/lib-index/mail-index.h Tue Jun 17 08:14:53 2008 +0300
+++ b/src/lib-index/mail-index.h Tue Jun 17 09:56:28 2008 +0300
@@ -306,9 +306,9 @@ int mail_index_fsck(struct mail_index *i
/* Synchronize changes in view. You have to go through all records, or view
will be marked inconsistent. Only sync_mask type records are
synchronized. */
-int mail_index_view_sync_begin(struct mail_index_view *view,
- enum mail_index_view_sync_flags flags,
- struct mail_index_view_sync_ctx **ctx_r);
+struct mail_index_view_sync_ctx *
+mail_index_view_sync_begin(struct mail_index_view *view,
+ enum mail_index_view_sync_flags flags);
bool mail_index_view_sync_next(struct mail_index_view_sync_ctx *ctx,
struct mail_index_view_sync_rec *sync_rec);
void
diff -r 6718f97ed2c3 -r 3882c6cbfa99 src/lib-storage/index/index-sync.c
--- a/src/lib-storage/index/index-sync.c Tue Jun 17 08:14:53 2008 +0300
+++ b/src/lib-storage/index/index-sync.c Tue Jun 17 09:56:28 2008 +0300
@@ -182,13 +182,7 @@ index_mailbox_sync_init(struct mailbox *
mail_index_view_get_messages_count(ibox->view);
}
- if (mail_index_view_sync_begin(ibox->view, sync_flags,
- &ctx->sync_ctx) < 0) {
- mail_storage_set_index_error(ibox);
- ctx->failed = TRUE;
- return &ctx->ctx;
- }
-
+ ctx->sync_ctx = mail_index_view_sync_begin(ibox->view, sync_flags);
if ((flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) == 0) {
mail_index_view_sync_get_expunges(ctx->sync_ctx,
&ctx->expunges);
More information about the dovecot-cvs
mailing list