From: Timo Sirainen Date: Sat, 22 Nov 2008 21:53:00 +0000 (+0200) Subject: mail_storage.search_next_update_seq returns now bool. It was never failing. X-Git-Tag: 1.2.alpha4~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bd1b2615928a1e8be190cb0405754f0aec8cac2f;p=thirdparty%2Fdovecot%2Fcore.git mail_storage.search_next_update_seq returns now bool. It was never failing. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/index-search.c b/src/lib-storage/index/index-search.c index d3a1cf5f3f..311f0c7787 100644 --- a/src/lib-storage/index/index-search.c +++ b/src/lib-storage/index/index-search.c @@ -1164,8 +1164,7 @@ int index_storage_search_next_nonblock(struct mail_search_context *_ctx, 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 @@ int index_storage_search_next_nonblock(struct mail_search_context *_ctx, 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 @@ int index_storage_search_next_nonblock(struct mail_search_context *_ctx, } 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 @@ int index_storage_search_next_nonblock(struct mail_search_context *_ctx, 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 @@ int index_storage_search_next_nonblock(struct mail_search_context *_ctx, 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 @@ int index_storage_search_next_nonblock(struct mail_search_context *_ctx, 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 @@ int index_storage_search_next_update_seq(struct mail_search_context *_ctx) } 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 @@ int index_storage_search_next_update_seq(struct mail_search_context *_ctx) _ctx->seq++; mail_search_args_reset(ctx->mail_ctx.args->args, FALSE); } - return ret == 0 ? 0 : 1; + return ret != 0; } diff --git a/src/lib-storage/index/index-storage.h b/src/lib-storage/index/index-storage.h index db3906b4f6..b0c7e8df20 100644 --- a/src/lib-storage/index/index-storage.h +++ b/src/lib-storage/index/index-storage.h @@ -168,7 +168,7 @@ int index_storage_search_next(struct mail_search_context *ctx, 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); diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index ba8ed01213..54e0e44c0e 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -158,7 +158,7 @@ struct mailbox_vfuncs { 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); diff --git a/src/plugins/fts/fts-storage.c b/src/plugins/fts/fts-storage.c index 8373277145..7c06162ca0 100644 --- a/src/plugins/fts/fts-storage.c +++ b/src/plugins/fts/fts-storage.c @@ -424,15 +424,14 @@ fts_mailbox_search_args_definite_set(struct fts_search_context *fctx) } } -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 @@ static int fts_mailbox_search_next_update_seq(struct mail_search_context *ctx) 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 @@ static int fts_mailbox_search_next_update_seq(struct mail_search_context *ctx) /* 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);