dovecot-1.1: fts: If we haven't indexed all messages, search the...

dovecot at dovecot.org dovecot at dovecot.org
Thu Nov 6 02:21:39 EET 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/c54f85111fc0
changeset: 7998:c54f85111fc0
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Nov 06 02:21:34 2008 +0200
description:
fts: If we haven't indexed all messages, search the rest using non-indexed search.
Typically this happens with header searches which don't force an index update.

diffstat:

2 files changed, 17 insertions(+), 5 deletions(-)
src/plugins/fts/fts-storage.c |   21 ++++++++++++++++-----
src/plugins/fts/fts-storage.h |    1 +

diffs (75 lines):

diff -r 700f12f0c5b2 -r c54f85111fc0 src/plugins/fts/fts-storage.c
--- a/src/plugins/fts/fts-storage.c	Wed Nov 05 14:23:22 2008 +0200
+++ b/src/plugins/fts/fts-storage.c	Thu Nov 06 02:21:34 2008 +0200
@@ -186,10 +186,12 @@ static int fts_build_init(struct fts_sea
 	memset(&seqset, 0, sizeof(seqset));
 	mailbox_get_uids(t->box, last_uid+1, (uint32_t)-1,
 			 &seqset.seq1, &seqset.seq2);
+	fctx->first_nonindexed_seq = seqset.seq1;
 	if (seqset.seq1 == 0) {
 		/* no new messages */
 		return 0;
 	}
+
 	if (fctx->best_arg->type == SEARCH_HEADER ||
 	    fctx->best_arg->type == SEARCH_HEADER_COMPRESS_LWSP) {
 		/* we're not updating the index just for header lookups */
@@ -205,6 +207,7 @@ static int fts_build_init(struct fts_sea
 		last_uid = last_uid_locked;
 		mailbox_get_uids(t->box, last_uid+1, (uint32_t)-1,
 				 &seqset.seq1, &seqset.seq2);
+		fctx->first_nonindexed_seq = seqset.seq1;
 		if (seqset.seq1 == 0) {
 			/* no new messages */
 			(void)fts_backend_build_deinit(&build);
@@ -391,9 +394,12 @@ static int fts_mailbox_search_next_nonbl
 		}
 
 		/* finished / error */
-		fts_build_deinit(&fctx->build_ctx);
-		if (ret > 0)
+		if (fts_build_deinit(&fctx->build_ctx) < 0)
+			ret = -1;
+		if (ret > 0) {
+			fctx->first_nonindexed_seq = 0;
 			fts_search_lookup(fctx);
+		}
 	}
 
 	/* if we're here, the indexes are either built or they're not used */
@@ -451,8 +457,13 @@ static int fts_mailbox_search_next_updat
 		/* use whichever is lower of definite/maybe */
 		if (fctx->definite_idx == def_count) {
 			if (fctx->maybe_idx == maybe_count) {
-				/* we're finished */
-				return 0;
+				/* look for the non-indexed mails */
+				if (fctx->first_nonindexed_seq == 0)
+					return 0;
+				fctx->seqs_set = FALSE;
+				ctx->seq = fctx->first_nonindexed_seq - 1;
+				return fbox->module_ctx.super.
+					search_next_update_seq(ctx);
 			}
 			use_maybe = TRUE;
 		} else if (fctx->maybe_idx == maybe_count) {
@@ -507,7 +518,7 @@ static int fts_mailbox_search_deinit(str
 
 	if (fctx->build_ctx != NULL) {
 		/* the search was cancelled */
-		fts_build_deinit(&fctx->build_ctx);
+		(void)fts_build_deinit(&fctx->build_ctx);
 	}
 
 	if (array_is_created(&fctx->definite_seqs))
diff -r 700f12f0c5b2 -r c54f85111fc0 src/plugins/fts/fts-storage.h
--- a/src/plugins/fts/fts-storage.h	Wed Nov 05 14:23:22 2008 +0200
+++ b/src/plugins/fts/fts-storage.h	Thu Nov 06 02:21:34 2008 +0200
@@ -23,6 +23,7 @@ struct fts_search_context {
 	ARRAY_TYPE(seq_range) definite_seqs, maybe_seqs;
 	ARRAY_TYPE(fts_score_map) score_map;
 	unsigned int definite_idx, maybe_idx;
+	uint32_t first_nonindexed_seq;
 
 	struct fts_backend *build_backend;
 	struct fts_storage_build_context *build_ctx;


More information about the dovecot-cvs mailing list