Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7833:c6a49099a4fc HEAD
threading left search parameters broken when returning.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 12 Jun 2008 02:54:39 +0300 |
parents | e1c13a782399 |
children | 2ac2ca9089bf |
files | src/lib-storage/index/index-thread.c |
diffstat | 1 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-thread.c Thu Jun 12 02:24:03 2008 +0300 +++ b/src/lib-storage/index/index-thread.c Thu Jun 12 02:54:39 2008 +0300 @@ -26,6 +26,7 @@ struct mailbox_transaction_context *t; struct mail_search_context *search; + struct mail_search_args *search_args; struct mail_search_arg tmp_search_arg; }; @@ -178,9 +179,9 @@ static bool mail_thread_try_use_hash(struct mail_thread_context *ctx, struct mail_hash *hash, - const struct mailbox_status *status, bool reset, - struct mail_search_args *search_args) + const struct mailbox_status *status, bool reset) { + struct mail_search_args *search_args = ctx->search_args; struct mail_search_arg *limit_arg = NULL; const struct mail_hash_header *hdr; struct mail_hash_transaction *hash_trans; @@ -309,8 +310,7 @@ } static void -mail_thread_update_init(struct mail_thread_context *ctx, - struct mail_search_args *search_args, bool reset) +mail_thread_update_init(struct mail_thread_context *ctx, bool reset) { struct mail_thread_mailbox *tbox = MAIL_THREAD_CONTEXT(ctx->box); struct mail_hash *hash = NULL; @@ -319,8 +319,7 @@ unsigned int count; mailbox_get_status(ctx->box, STATUS_MESSAGES | STATUS_UIDNEXT, &status); - if (mail_thread_try_use_hash(ctx, tbox->hash, &status, - reset, search_args)) + if (mail_thread_try_use_hash(ctx, tbox->hash, &status, reset)) hash = tbox->hash; else { /* fallback to using in-memory hash */ @@ -343,7 +342,7 @@ /* initialize searching */ ctx->t = mailbox_transaction_begin(ctx->box, 0); - ctx->search = mailbox_search_init(ctx->t, search_args, NULL); + ctx->search = mailbox_search_init(ctx->t, ctx->search_args, NULL); ctx->thread_ctx.tmp_mail = mail_alloc(ctx->t, 0, NULL); hdr = mail_hash_get_header(ctx->thread_ctx.hash_trans); @@ -357,10 +356,8 @@ I_MAX(hdr->record_count, status.messages)); } - static int -mail_thread_update(struct mail_thread_context *ctx, - struct mail_search_args *search_args, bool reset) +mail_thread_update(struct mail_thread_context *ctx, bool reset) { static const char *wanted_headers[] = { HDR_MESSAGE_ID, HDR_IN_REPLY_TO, HDR_REFERENCES, HDR_SUBJECT, @@ -374,7 +371,7 @@ uint32_t prev_uid; int ret = 0; - mail_thread_update_init(ctx, search_args, reset); + mail_thread_update_init(ctx, reset); box = mailbox_transaction_get_mailbox(ctx->t); hdr = mail_hash_get_header(ctx->thread_ctx.hash_trans); @@ -419,8 +416,9 @@ ctx = i_new(struct mail_thread_context, 1); tbox->ctx = &ctx->thread_ctx; ctx->box = box; + ctx->search_args = args; - while ((ret = mail_thread_update(ctx, args, reset)) < 0) { + while ((ret = mail_thread_update(ctx, reset)) < 0) { if (ctx->thread_ctx.hash == tbox->hash) { /* failed with in-memory hash */ mail_thread_deinit(&ctx); @@ -455,6 +453,9 @@ *_ctx = NULL; + if (ctx->search_args->args == &ctx->tmp_search_arg) + ctx->search_args->args = ctx->tmp_search_arg.next; + mail_hash_transaction_end(&ctx->thread_ctx.hash_trans); ret = mailbox_search_deinit(&ctx->search);