Mercurial > dovecot > core-2.3
changeset 26386:b7e38a84822a
lib-storage: Move tracking mails to mail_search_context from index-specific code
This makes the next commit much easier to implement.
author | Timo Sirainen <timo.sirainen@open-xchange.com> |
---|---|
date | Thu, 28 Feb 2019 15:03:22 +0200 |
parents | 214725a0cd17 |
children | abc556a15a89 |
files | src/lib-storage/index/index-search-private.h src/lib-storage/index/index-search.c src/lib-storage/mail-storage-private.h |
diffstat | 3 files changed, 26 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-search-private.h Thu Feb 28 15:08:38 2019 +0200 +++ b/src/lib-storage/index/index-search-private.h Thu Feb 28 15:03:22 2019 +0200 @@ -23,10 +23,6 @@ struct index_mail *cur_imail; struct mail_thread_context *thread_ctx; - ARRAY(struct mail *) mails; - unsigned int unused_mail_idx; - unsigned int max_mails; - struct timeval search_start_time, last_notify; struct timeval last_nonblock_timeval; unsigned long long cost, next_time_check_cost;
--- a/src/lib-storage/index/index-search.c Thu Feb 28 15:08:38 2019 +0200 +++ b/src/lib-storage/index/index-search.c Thu Feb 28 15:03:22 2019 +0200 @@ -1284,9 +1284,9 @@ ctx->mail_ctx.args = args; ctx->mail_ctx.sort_program = index_sort_program_init(t, sort_program); - ctx->max_mails = t->box->storage->set->mail_prefetch_count + 1; - if (ctx->max_mails == 0) - ctx->max_mails = UINT_MAX; + ctx->mail_ctx.max_mails = t->box->storage->set->mail_prefetch_count + 1; + if (ctx->mail_ctx.max_mails == 0) + ctx->mail_ctx.max_mails = UINT_MAX; ctx->next_time_check_cost = SEARCH_INITIAL_MAX_COST; if (gettimeofday(&ctx->last_nonblock_timeval, NULL) < 0) i_fatal("gettimeofday() failed: %m"); @@ -1297,7 +1297,7 @@ i_array_init(&ctx->mail_ctx.results, 5); array_create(&ctx->mail_ctx.module_contexts, default_pool, sizeof(void *), 5); - i_array_init(&ctx->mails, ctx->max_mails); + i_array_init(&ctx->mail_ctx.mails, ctx->mail_ctx.max_mails); mail_search_args_reset(ctx->mail_ctx.args->args, TRUE); if (args->have_inthreads) { @@ -1364,7 +1364,7 @@ array_free(&ctx->mail_ctx.results); array_free(&ctx->mail_ctx.module_contexts); - array_foreach_modifiable(&ctx->mails, mailp) { + array_foreach_modifiable(&ctx->mail_ctx.mails, mailp) { struct index_mail *imail = INDEX_MAIL(*mailp); imail->mail.search_mail = FALSE; @@ -1373,7 +1373,7 @@ if (ctx->failed) mail_storage_last_error_pop(ctx->box->storage); - array_free(&ctx->mails); + array_free(&ctx->mail_ctx.mails); i_free(ctx); return ret; } @@ -1493,7 +1493,7 @@ } /* avoid doing extra work for as long as possible */ - if (ctx->max_mails > 1) { + if (ctx->mail_ctx.max_mails > 1) { /* we're doing prefetching. if we have to read the mail, do a prefetch first and the final search later */ n--; @@ -1675,12 +1675,12 @@ struct mail *const *mails, *mail; unsigned int count; - if (ctx->unused_mail_idx == ctx->max_mails) + if (ctx->mail_ctx.unused_mail_idx == ctx->mail_ctx.max_mails) return NULL; - mails = array_get(&ctx->mails, &count); - if (ctx->unused_mail_idx < count) - return mails[ctx->unused_mail_idx]; + mails = array_get(&ctx->mail_ctx.mails, &count); + if (ctx->mail_ctx.unused_mail_idx < count) + return mails[ctx->mail_ctx.unused_mail_idx]; mail = mail_alloc(ctx->mail_ctx.transaction, ctx->mail_ctx.wanted_fields, @@ -1689,7 +1689,7 @@ imail->mail.search_mail = TRUE; ctx->mail_ctx.transaction->stats_track = TRUE; - array_push_back(&ctx->mails, &mail); + array_push_back(&ctx->mail_ctx.mails, &mail); return mail; } @@ -1710,16 +1710,16 @@ if (ctx->mail_ctx.sort_program != NULL) { /* don't prefetch when using a sort program, since the mails' access order will change */ - i_assert(ctx->unused_mail_idx == 0); + i_assert(ctx->mail_ctx.unused_mail_idx == 0); *mail_r = mail; return 1; } - if (mail_prefetch(mail) && ctx->unused_mail_idx == 0) { + if (mail_prefetch(mail) && ctx->mail_ctx.unused_mail_idx == 0) { /* no prefetching done, return it immediately */ *mail_r = mail; return 1; } - ctx->unused_mail_idx++; + ctx->mail_ctx.unused_mail_idx++; } if (mail != NULL) { @@ -1728,7 +1728,7 @@ return 0; } i_assert(ret < 0); - if (ctx->unused_mail_idx == 0) { + if (ctx->mail_ctx.unused_mail_idx == 0) { /* finished */ return -1; } @@ -1737,13 +1737,13 @@ } /* return the next message */ - i_assert(ctx->unused_mail_idx > 0); + i_assert(ctx->mail_ctx.unused_mail_idx > 0); - mails = array_get(&ctx->mails, &count); + mails = array_get(&ctx->mail_ctx.mails, &count); *mail_r = mails[0]; - if (--ctx->unused_mail_idx > 0) { - array_pop_front(&ctx->mails); - array_push_back(&ctx->mails, mail_r); + if (--ctx->mail_ctx.unused_mail_idx > 0) { + array_pop_front(&ctx->mail_ctx.mails); + array_push_back(&ctx->mail_ctx.mails, mail_r); } index_mail_update_access_parts_post(*mail_r); return 1; @@ -1834,7 +1834,7 @@ if (!index_sort_list_next(_ctx->sort_program, &seq)) return FALSE; - mailp = array_front(&ctx->mails); + mailp = array_front(&ctx->mail_ctx.mails); mail_set_seq(*mailp, seq); index_mail_update_access_parts_pre(*mailp); index_mail_update_access_parts_post(*mailp);
--- a/src/lib-storage/mail-storage-private.h Thu Feb 28 15:08:38 2019 +0200 +++ b/src/lib-storage/mail-storage-private.h Thu Feb 28 15:03:22 2019 +0200 @@ -655,6 +655,10 @@ uint32_t seq; uint32_t progress_cur, progress_max; + ARRAY(struct mail *) mails; + unsigned int unused_mail_idx; + unsigned int max_mails; + ARRAY(union mail_search_module_context *) module_contexts; bool seen_lost_data:1;