dovecot: Optimization: Refresh index before opening view instead...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Jul 18 07:31:49 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/f5d87227d12c
changeset: 6067:f5d87227d12c
user: Timo Sirainen <tss at iki.fi>
date: Wed Jul 18 07:31:43 2007 +0300
description:
Optimization: Refresh index before opening view instead of syncing the
opened view.
diffstat:
1 file changed, 8 insertions(+), 23 deletions(-)
src/lib-storage/list/index-mailbox-list.c | 31 +++++++----------------------
diffs (60 lines):
diff -r bba5f170a565 -r f5d87227d12c src/lib-storage/list/index-mailbox-list.c
--- 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,33 +58,11 @@ index_mailbox_list_info_flags_translate(
}
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) {
@@ -237,6 +215,13 @@ index_mailbox_list_iter_init(struct mail
}
}
+ /* 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 @@ index_mailbox_list_iter_init(struct mail
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);
More information about the dovecot-cvs
mailing list