Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7872:3882c6cbfa99 HEAD
mail_index_view_sync_begin() now delays its failures to _commit().
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 17 Jun 2008 09:56:28 +0300 |
parents | 6718f97ed2c3 |
children | af9d5fd1071c |
files | src/lib-index/mail-index-view-sync.c src/lib-index/mail-index.h src/lib-storage/index/index-sync.c |
diffstat | 3 files changed, 27 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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; @@ -277,13 +277,20 @@ 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)) { if ((flags & MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT) == 0) { 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 @@ 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->failed = TRUE; + return ctx; } - ctx = i_new(struct mail_index_view_sync_ctx, 1); - ctx->view = view; - ctx->flags = flags; ctx->expunges = expunges; ctx->finish_min_msg_count = reset || quick_sync ? 0 : view->map->hdr.messages_count - expunge_count; @@ -366,10 +374,7 @@ /* 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 @@ 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 @@ 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
--- 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 @@ /* 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
--- 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 @@ 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);