]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Add asserts to make sure lookup_abort is being used correctly.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 20 Feb 2017 17:35:45 +0000 (19:35 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 21 Feb 2017 12:57:07 +0000 (14:57 +0200)
src/lib-storage/index/index-search.c
src/lib-storage/index/index-sort.c

index 70b377e7c87d8da4a8a03caccb5b8a8dd82f3021..9ffcc10d4bd2b70b6eea0d707b47f9bde3a9e7c9 100644 (file)
@@ -1479,6 +1479,8 @@ static int search_match_next(struct index_search_context *ctx)
                   do a prefetch first and the final search later */
                n--;
        }
+
+       i_assert(ctx->cur_mail->lookup_abort == MAIL_LOOKUP_ABORT_NEVER);
        for (i = 0; i < n && ret < 0; i++) {
                ctx->cur_mail->lookup_abort = cache_lookups[i];
                T_BEGIN {
index a7cae3b216a811f0f8421de00c0db306db5491b5..18951ff773bd1356ce3f7ace4a8b605944afe08f 100644 (file)
@@ -45,6 +45,7 @@ index_sort_program_set_mail_failed(struct mail_search_sort_program *program,
                break;
        case MAIL_ERROR_LOOKUP_ABORTED:
                /* just change the error message */
+               i_assert(program->slow_mails_left == 0);
                mail_storage_set_error(program->t->box->storage, MAIL_ERROR_LIMIT,
                        "Requested sort would have taken too long.");
                /* fall through */
@@ -169,12 +170,14 @@ index_sort_list_add_relevancy(struct mail_search_sort_program *program,
 void index_sort_list_add(struct mail_search_sort_program *program,
                         struct mail *mail)
 {
-       enum mail_lookup_abort orig_abort = mail->lookup_abort;
        enum mail_access_type orig_access_type = mail->access_type;
        bool prev_slow = mail->mail_stream_opened ||
                mail->mail_metadata_accessed;
 
        i_assert(mail->transaction == program->t);
+       /* if lookup_abort isn't NEVER, mail_sort_max_read_count handling
+          doesn't work right. */
+       i_assert(mail->lookup_abort == MAIL_LOOKUP_ABORT_NEVER);
 
        if (program->slow_mails_left == 0)
                mail->lookup_abort = MAIL_LOOKUP_ABORT_NOT_IN_CACHE;
@@ -190,7 +193,7 @@ void index_sort_list_add(struct mail_search_sort_program *program,
                i_assert(program->slow_mails_left > 0);
                program->slow_mails_left--;
        }
-       mail->lookup_abort = orig_abort;
+       mail->lookup_abort = MAIL_LOOKUP_ABORT_NEVER;
 }
 
 static int sort_node_date_cmp(const struct mail_sort_node_date *n1,