Mercurial > dovecot > core-2.2
changeset 12608:b96efbad2fa4
lib-storage: Index search context is now more accessible by backends.
Moved struct index_search_context to index-search-private.h and added
recheck_index_args flag that backends can set.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 30 Jan 2011 20:16:04 +0200 |
parents | 40f668d36547 |
children | 391ba80cb125 |
files | src/lib-storage/index/Makefile.am src/lib-storage/index/index-search-private.h src/lib-storage/index/index-search.c |
diffstat | 3 files changed, 63 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/Makefile.am Sun Jan 30 17:51:17 2011 +0200 +++ b/src/lib-storage/index/Makefile.am Sun Jan 30 20:16:04 2011 +0200 @@ -40,6 +40,7 @@ istream-mail-stats.h \ index-attachment.h \ index-mail.h \ + index-search-private.h \ index-search-result.h \ index-sort.h \ index-sort-private.h \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-storage/index/index-search-private.h Sun Jan 30 20:16:04 2011 +0200 @@ -0,0 +1,35 @@ +#ifndef INDEX_SEARCH_PRIVATE_H +#define INDEX_SEARCH_PRIVATE_H + +#include "mail-storage-private.h" + +struct index_search_context { + struct mail_search_context mail_ctx; + struct mail_index_view *view; + struct mailbox *box; + + uint32_t seq1, seq2; + struct mail *mail; + struct index_mail *imail; + struct mail_thread_context *thread_ctx; + + const char *error; + + struct timeval search_start_time, last_notify; + struct timeval last_nonblock_timeval; + unsigned long long cost, next_time_check_cost; + + unsigned int failed:1; + unsigned int sorted:1; + unsigned int have_seqsets:1; + unsigned int have_index_args:1; + unsigned int have_mailbox_args:1; + unsigned int recheck_index_args:1; +}; + +void index_storage_search_init_context(struct index_search_context *ctx, + struct mailbox_transaction_context *t, + struct mail_search_args *args, + const enum mail_sort_type *sort_program); + +#endif
--- a/src/lib-storage/index/index-search.c Sun Jan 30 17:51:17 2011 +0200 +++ b/src/lib-storage/index/index-search.c Sun Jan 30 20:16:04 2011 +0200 @@ -18,6 +18,7 @@ #include "index-sort.h" #include "mail-search.h" #include "mailbox-search-result-private.h" +#include "index-search-private.h" #include <stdlib.h> #include <ctype.h> @@ -38,29 +39,6 @@ #define SEARCH_INITIAL_MAX_COST 30000 #define SEARCH_RECALC_MIN_USECS 50000 -struct index_search_context { - struct mail_search_context mail_ctx; - struct mail_index_view *view; - struct mailbox *box; - - uint32_t seq1, seq2; - struct mail *mail; - struct index_mail *imail; - struct mail_thread_context *thread_ctx; - - const char *error; - - struct timeval search_start_time, last_notify; - struct timeval last_nonblock_timeval; - unsigned long long cost, next_time_check_cost; - - unsigned int failed:1; - unsigned int sorted:1; - unsigned int have_seqsets:1; - unsigned int have_index_args:1; - unsigned int have_mailbox_args:1; -}; - struct search_header_context { struct index_search_context *index_context; struct mail_search_arg *args; @@ -1062,15 +1040,13 @@ return ret; } -struct mail_search_context * -index_storage_search_init(struct mailbox_transaction_context *t, - struct mail_search_args *args, - const enum mail_sort_type *sort_program) +void index_storage_search_init_context(struct index_search_context *ctx, + struct mailbox_transaction_context *t, + struct mail_search_args *args, + const enum mail_sort_type *sort_program) { - struct index_search_context *ctx; struct mailbox_status status; - ctx = i_new(struct index_search_context, 1); ctx->mail_ctx.transaction = t; ctx->box = t->box; ctx->view = t->view; @@ -1100,6 +1076,17 @@ /* Need to reset results for match_always cases */ mail_search_args_reset(ctx->mail_ctx.args->args, FALSE); +} + +struct mail_search_context * +index_storage_search_init(struct mailbox_transaction_context *t, + struct mail_search_args *args, + const enum mail_sort_type *sort_program) +{ + struct index_search_context *ctx; + + ctx = i_new(struct index_search_context, 1); + index_storage_search_init_context(ctx, t, args, sort_program); return &ctx->mail_ctx; } @@ -1150,6 +1137,17 @@ unsigned int i; int ret = -1; + if (ctx->recheck_index_args) { + /* these were already checked in search_next_update_seq(), + but someone reset the args and we have to recheck them */ + ret = mail_search_args_foreach(ctx->mail_ctx.args->args, + search_seqset_arg, ctx); + if (ctx->have_index_args) { + ret = mail_search_args_foreach(ctx->mail_ctx.args->args, + search_index_arg, ctx); + } + } + if (ctx->have_mailbox_args) { ret = mail_search_args_foreach(ctx->mail_ctx.args->args, search_mailbox_arg, ctx);