]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mail_storage.search_next_update_seq returns now bool. It was never failing.
authorTimo Sirainen <tss@iki.fi>
Sat, 22 Nov 2008 21:53:00 +0000 (23:53 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 22 Nov 2008 21:53:00 +0000 (23:53 +0200)
--HG--
branch : HEAD

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

index d3a1cf5f3f1bdabe449942bc5fc338759506a1f7..311f0c77872c5f977fc19c08ebe73a03a1c292ed 100644 (file)
@@ -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;
 }
index db3906b4f6fa9616ed734526961b0e3f4b8616cd..b0c7e8df204da1b380ca7cbc5d806f8cabb962a8 100644 (file)
@@ -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);
index ba8ed012135d2283e2355864fc038114f4dbeec8..54e0e44c0ef8da870af67641bd9e978a1ed88aa2 100644 (file)
@@ -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);
index 83732771450ab9296b5a5c28175eab0e595e3af5..7c06162ca0cdaefa7f10711aceeef3ff16d01032 100644 (file)
@@ -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);