Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6067:f5d87227d12c HEAD
Optimization: Refresh index before opening view instead of syncing the
opened view.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 18 Jul 2007 07:31:43 +0300 |
parents | bba5f170a565 |
children | dc93705c4038 |
files | src/lib-storage/list/index-mailbox-list.c |
diffstat | 1 files changed, 8 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/list/index-mailbox-list.c Wed Jul 18 06:49:22 2007 +0300 +++ b/src/lib-storage/list/index-mailbox-list.c Wed Jul 18 07:31:43 2007 +0300 @@ -58,34 +58,12 @@ } static int -index_mailbox_view_sync(struct index_mailbox_list_iterate_context *ctx) -{ - struct mail_index_view_sync_ctx *sync_ctx; - struct mail_index_view_sync_rec sync_rec; - int ret; - - if (mail_index_view_sync_begin(ctx->mail_view, 0, - &sync_ctx) < 0) { - mailbox_list_set_internal_error(ctx->ctx.list); - return -1; - } - - while ((ret = mail_index_view_sync_next(sync_ctx, &sync_rec)) > 0) ; - - mail_index_view_sync_end(&sync_ctx); - return ret; -} - -static int index_mailbox_list_is_synced(struct index_mailbox_list_iterate_context *ctx) { const struct mail_index_header *hdr; struct stat st; const char *path = ctx->ctx.list->set.root_dir; - if (index_mailbox_view_sync(ctx) < 0) - return -1; - /* FIXME: single sync_stamp works only with maildir++ */ if (stat(path, &st) < 0) { mailbox_list_set_critical(ctx->ctx.list, @@ -237,6 +215,13 @@ } } + /* Refresh index before opening our view */ + if (mail_index_refresh(ilist->mail_index) < 0) { + ctx->backend_ctx = ilist->module_ctx.super. + iter_init(list, patterns, flags); + return &ctx->ctx; + } + ctx->mail_view = mail_index_view_open(ilist->mail_index); ctx->view = mailbox_list_index_view_init(ilist->list_index, ctx->mail_view); @@ -254,7 +239,7 @@ if (prefix == NULL) prefix = ""; - if (!index_mailbox_list_is_synced(ctx) > 0) { + if (index_mailbox_list_is_synced(ctx) <= 0) { ret = index_mailbox_list_sync(ctx); mail_index_view_close(&ctx->mail_view);