return ret;
}
+int index_storage_search_next_match_mail(struct mail_search_context *_ctx,
+ struct mail *mail)
+{
+ struct index_search_context *ctx =
+ container_of(_ctx, struct index_search_context, mail_ctx);
+ struct index_mail *imail = INDEX_MAIL(mail);
+ int match;
+
+ ctx->cur_mail = mail;
+ /* mail's access_type is SEARCH only while using it to process
+ the search query. afterwards the mail can still be accessed
+ for fetching. */
+ ctx->cur_mail->access_type = MAIL_ACCESS_TYPE_SEARCH;
+ T_BEGIN {
+ match = search_match_next(ctx);
+ } T_END;
+ ctx->cur_mail->access_type = MAIL_ACCESS_TYPE_DEFAULT;
+ ctx->cur_mail = NULL;
+
+ i_assert(imail->data.search_results == NULL);
+ if (match < 0) {
+ /* result isn't known yet, do a prefetch and
+ finish later */
+ imail->data.search_results =
+ buffer_create_dynamic(imail->mail.data_pool, 64);
+ mail_search_args_result_serialize(_ctx->args,
+ imail->data.search_results);
+ }
+
+ mail_search_args_reset(_ctx->args->args, FALSE);
+
+ if (match != 0) {
+ /* either matched or result is still unknown.
+ anyway we're far enough now that we probably want
+ to update the access_parts. the only problem here is
+ if searching would want fewer access_parts than the
+ fetching part, but that's probably not a big problem
+ usually. */
+ index_mail_update_access_parts_pre(mail);
+ return 1;
+ }
+
+ /* non-match */
+ if (_ctx->args->stop_on_nonmatch)
+ return -1;
+ return 0;
+}
+
static int search_more_with_mail(struct index_search_context *ctx,
struct mail *mail)
{
struct mail_search_context *_ctx = &ctx->mail_ctx;
struct mailbox *box = _ctx->transaction->box;
- struct index_mail *imail = INDEX_MAIL(mail);
unsigned long long cost1, cost2;
- int match, ret;
+ int ret;
if (search_would_block(ctx)) {
/* this lookup is useful when a large number of
while (box->v.search_next_update_seq(_ctx)) {
mail_set_seq(mail, _ctx->seq);
- ctx->cur_mail = mail;
- /* mail's access_type is SEARCH only while using it to process
- the search query. afterwards the mail can still be accessed
- for fetching. */
- ctx->cur_mail->access_type = MAIL_ACCESS_TYPE_SEARCH;
- T_BEGIN {
- match = search_match_next(ctx);
- } T_END;
- ctx->cur_mail->access_type = MAIL_ACCESS_TYPE_DEFAULT;
- ctx->cur_mail = NULL;
-
- i_assert(imail->data.search_results == NULL);
- if (match < 0) {
- /* result isn't known yet, do a prefetch and
- finish later */
- imail->data.search_results =
- buffer_create_dynamic(imail->mail.data_pool, 64);
- mail_search_args_result_serialize(_ctx->args,
- imail->data.search_results);
- }
-
- mail_search_args_reset(_ctx->args->args, FALSE);
-
- if (match != 0) {
- /* either matched or result is still unknown.
- anyway we're far enough now that we probably want
- to update the access_parts. the only problem here is
- if searching would want fewer access_parts than the
- fetching part, but that's probably not a big problem
- usually. */
- index_mail_update_access_parts_pre(mail);
- ret = 1;
- break;
- }
-
- /* non-match */
- if (_ctx->args->stop_on_nonmatch) {
- ret = -1;
+ ret = box->v.search_next_match_mail(_ctx, mail);
+ if (ret != 0)
break;
- }
cost2 = search_get_cost(mail->transaction);
ctx->cost += cost2 - cost1;
cost1 = cost2;
- if (search_would_block(ctx)) {
- ret = 0;
+ if (search_would_block(ctx))
break;
- }
+ ret = -1;
}
cost2 = search_get_cost(mail->transaction);
ctx->cost += cost2 - cost1;