dovecot-1.2: mail_storage.search_next_update_seq returns now boo...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Nov 23 02:40:15 EET 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/c033b3e2d9b6
changeset: 8477:c033b3e2d9b6
user: Timo Sirainen <tss at iki.fi>
date: Sat Nov 22 23:53:00 2008 +0200
description:
mail_storage.search_next_update_seq returns now bool. It was never failing.
diffstat:
4 files changed, 21 insertions(+), 25 deletions(-)
src/lib-storage/index/index-search.c | 33 ++++++++++++++------------------
src/lib-storage/index/index-storage.h | 2 -
src/lib-storage/mail-storage-private.h | 2 -
src/plugins/fts/fts-storage.c | 9 +++-----
diffs (160 lines):
diff -r 9bcc2dd5f17f -r c033b3e2d9b6 src/lib-storage/index/index-search.c
--- 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 @@ int index_storage_search_next_nonblock(s
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(s
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(s
}
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(s
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(s
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(s
tryagain_r);
}
- return ret;
-}
-
-int index_storage_search_next_update_seq(struct mail_search_context *_ctx)
+ return ctx->failed ? -1 : 0;
+}
+
+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
}
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
_ctx->seq++;
mail_search_args_reset(ctx->mail_ctx.args->args, FALSE);
}
- return ret == 0 ? 0 : 1;
-}
+ return ret != 0;
+}
diff -r 9bcc2dd5f17f -r c033b3e2d9b6 src/lib-storage/index/index-storage.h
--- 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 @@ int index_storage_search_next(struct mai
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 -r 9bcc2dd5f17f -r c033b3e2d9b6 src/lib-storage/mail-storage-private.h
--- 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 @@ 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 -r 9bcc2dd5f17f -r c033b3e2d9b6 src/plugins/fts/fts-storage.c
--- 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 @@ fts_mailbox_search_args_definite_set(str
}
}
-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_updat
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_updat
/* 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);
More information about the dovecot-cvs
mailing list