Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8477:c033b3e2d9b6 HEAD
mail_storage.search_next_update_seq returns now bool. It was never failing.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 22 Nov 2008 23:53:00 +0200 |
parents | 9bcc2dd5f17f |
children | adf36d9cd338 |
files | src/lib-storage/index/index-search.c src/lib-storage/index/index-storage.h src/lib-storage/mail-storage-private.h src/plugins/fts/fts-storage.c |
diffstat | 4 files changed, 18 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-search.c Fri Nov 21 22:57:50 2008 +0200 +++ b/src/lib-storage/index/index-search.c Sat Nov 22 23:53:00 2008 +0200 @@ -1164,8 +1164,7 @@ struct index_search_context *ctx = (struct index_search_context *)_ctx; struct mailbox *box = _ctx->transaction->box; unsigned int count = 0; - bool never; - int ret; + bool match, never; *tryagain_r = FALSE; @@ -1184,7 +1183,7 @@ SEARCH_NOTIFY_INTERVAL_SECS) index_storage_search_notify(box, ctx); - while ((ret = box->v.search_next_update_seq(_ctx)) > 0) { + while (box->v.search_next_update_seq(_ctx)) { mail_set_seq(mail, _ctx->seq); if (_ctx->update_result == NULL) @@ -1203,14 +1202,14 @@ } if (never) { - ret = 0; + match = FALSE; } else T_BEGIN { - ret = search_match_next(ctx) ? 1 : 0; + match = search_match_next(ctx); if (ctx->mail->expunged) _ctx->seen_lost_data = TRUE; - if (ret == 0 && + if (!match && search_has_static_nonmatches(_ctx->args->args)) { /* if there are saved search results remember that this message never matches */ @@ -1221,8 +1220,8 @@ mail_search_args_reset(_ctx->args->args, FALSE); if (ctx->error != NULL) - ret = -1; - if (ret != 0) { + ctx->failed = TRUE; + else if (match) { if (_ctx->sort_program == NULL) break; @@ -1234,12 +1233,10 @@ return 0; } } - if (ret < 0) - ctx->failed = TRUE; ctx->mail = NULL; ctx->imail = NULL; - if (_ctx->sort_program != NULL && ret == 0) { + if (_ctx->sort_program != NULL && !ctx->failed) { /* finished searching the messages. now sort them and start returning the messages. */ ctx->sorted = TRUE; @@ -1248,10 +1245,10 @@ tryagain_r); } - return ret; + return ctx->failed ? -1 : 0; } -int index_storage_search_next_update_seq(struct mail_search_context *_ctx) +bool index_storage_search_next_update_seq(struct mail_search_context *_ctx) { struct index_search_context *ctx = (struct index_search_context *)_ctx; int ret; @@ -1264,7 +1261,7 @@ } if (!ctx->have_seqsets && !ctx->have_index_args) - return _ctx->seq <= ctx->seq2 ? 1 : 0; + return _ctx->seq <= ctx->seq2; ret = 0; while (_ctx->seq <= ctx->seq2) { @@ -1286,5 +1283,5 @@ _ctx->seq++; mail_search_args_reset(ctx->mail_ctx.args->args, FALSE); } - return ret == 0 ? 0 : 1; + return ret != 0; }
--- a/src/lib-storage/index/index-storage.h Fri Nov 21 22:57:50 2008 +0200 +++ b/src/lib-storage/index/index-storage.h Sat Nov 22 23:53:00 2008 +0200 @@ -168,7 +168,7 @@ struct mail *mail); int index_storage_search_next_nonblock(struct mail_search_context *ctx, struct mail *mail, bool *tryagain_r); -int index_storage_search_next_update_seq(struct mail_search_context *ctx); +bool index_storage_search_next_update_seq(struct mail_search_context *ctx); void index_transaction_init(struct index_transaction_context *t, struct index_mailbox *ibox);
--- a/src/lib-storage/mail-storage-private.h Fri Nov 21 22:57:50 2008 +0200 +++ b/src/lib-storage/mail-storage-private.h Sat Nov 22 23:53:00 2008 +0200 @@ -158,7 +158,7 @@ int (*search_next_nonblock)(struct mail_search_context *ctx, struct mail *mail, bool *tryagain_r); /* Internal search function which updates ctx->seq */ - int (*search_next_update_seq)(struct mail_search_context *ctx); + bool (*search_next_update_seq)(struct mail_search_context *ctx); struct mail_save_context * (*save_alloc)(struct mailbox_transaction_context *t);
--- a/src/plugins/fts/fts-storage.c Fri Nov 21 22:57:50 2008 +0200 +++ b/src/plugins/fts/fts-storage.c Sat Nov 22 23:53:00 2008 +0200 @@ -424,15 +424,14 @@ } } -static int fts_mailbox_search_next_update_seq(struct mail_search_context *ctx) +static bool fts_mailbox_search_next_update_seq(struct mail_search_context *ctx) { struct fts_mailbox *fbox = FTS_CONTEXT(ctx->transaction->box); struct fts_search_context *fctx = FTS_CONTEXT(ctx); struct seq_range *def_range, *maybe_range, *range; unsigned int def_count, maybe_count; uint32_t wanted_seq; - bool use_maybe; - int ret; + bool use_maybe, ret; if (!fctx->seqs_set) return fbox->module_ctx.super.search_next_update_seq(ctx); @@ -457,7 +456,7 @@ if (fctx->maybe_idx == maybe_count) { /* look for the non-indexed mails */ if (fctx->first_nonindexed_seq == 0) - return 0; + return FALSE; fctx->seqs_set = FALSE; ctx->seq = fctx->first_nonindexed_seq - 1; return fbox->module_ctx.super. @@ -491,7 +490,7 @@ /* ctx->seq points to previous sequence we want */ ctx->seq = wanted_seq - 1; ret = fbox->module_ctx.super.search_next_update_seq(ctx); - if (ret <= 0 || wanted_seq == ctx->seq) + if (!ret || wanted_seq == ctx->seq) break; wanted_seq = ctx->seq; mail_search_args_reset(ctx->args->args, FALSE);