dovecot-2.2: fts: Added fts_enforced setting to disable fallback...
dovecot at dovecot.org
dovecot at dovecot.org
Fri May 22 02:22:22 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/b29b48376fb4
changeset: 18736:b29b48376fb4
user: Timo Sirainen <tss at iki.fi>
date: Thu May 21 22:20:10 2015 -0400
description:
fts: Added fts_enforced setting to disable fallbacking to slow search on errors.
diffstat:
src/plugins/fts/fts-storage.c | 17 +++++++++++++++--
src/plugins/fts/fts-storage.h | 1 +
2 files changed, 16 insertions(+), 2 deletions(-)
diffs (59 lines):
diff -r 5aae57dc5ad6 -r b29b48376fb4 src/plugins/fts/fts-storage.c
--- a/src/plugins/fts/fts-storage.c Thu May 21 22:03:10 2015 -0400
+++ b/src/plugins/fts/fts-storage.c Thu May 21 22:20:10 2015 -0400
@@ -215,6 +215,9 @@
fctx->orig_matches = buffer_create_dynamic(default_pool, 64);
fctx->virtual_mailbox =
strcmp(t->box->storage->name, VIRTUAL_STORAGE_NAME) == 0;
+ fctx->enforced =
+ mail_user_plugin_getenv(t->box->storage->user,
+ "fts_enforced") != NULL;
i_array_init(&fctx->levels, 8);
fctx->scores = i_new(struct fts_scores, 1);
fctx->scores->refcount = 1;
@@ -234,7 +237,7 @@
ft->scores = fctx->scores;
ft->scores->refcount++;
- if (fts_want_build_args(args->args))
+ if (fctx->enforced || fts_want_build_args(args->args))
fts_try_build_init(ctx, fctx);
else
fts_search_lookup(fctx);
@@ -277,7 +280,11 @@
struct fts_mailbox *fbox = FTS_CONTEXT(ctx->transaction->box);
struct fts_search_context *fctx = FTS_CONTEXT(ctx);
- if (fctx != NULL && fctx->indexer_ctx != NULL) {
+ if (fctx == NULL) {
+ /* no fts */
+ } else if (!fctx->fts_lookup_success && fctx->enforced) {
+ return FALSE;
+ } else if (fctx->indexer_ctx != NULL) {
/* this command is still building the indexes */
if (!fts_mailbox_build_continue(ctx)) {
*tryagain_r = TRUE;
@@ -362,6 +369,12 @@
}
if (fctx->indexing_timed_out)
ret = -1;
+ if (!fctx->fts_lookup_success && fctx->enforced) {
+ /* FTS lookup failed and we didn't want to fallback to
+ opening all the mails and searching manually */
+ mail_storage_set_internal_error(ctx->transaction->box->storage);
+ ret = -1;
+ }
buffer_free(&fctx->orig_matches);
array_free(&fctx->levels);
diff -r 5aae57dc5ad6 -r b29b48376fb4 src/plugins/fts/fts-storage.h
--- a/src/plugins/fts/fts-storage.h Thu May 21 22:03:10 2015 -0400
+++ b/src/plugins/fts/fts-storage.h Thu May 21 22:20:10 2015 -0400
@@ -38,6 +38,7 @@
unsigned int virtual_mailbox:1;
unsigned int fts_lookup_success:1;
unsigned int indexing_timed_out:1;
+ unsigned int enforced:1;
};
/* Figure out if we want to use full text search indexes and update
More information about the dovecot-cvs
mailing list