dovecot-2.2: fts: Don't always try to initialize lib-fts. Requir...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Apr 24 11:10:28 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/6d5240e7d344
changeset: 18472:6d5240e7d344
user: Timo Sirainen <tss at iki.fi>
date: Fri Apr 24 14:08:39 2015 +0300
description:
fts: Don't always try to initialize lib-fts. Require backend to explictly do it now.
diffstat:
src/plugins/fts-lucene/fts-lucene-plugin.c | 9 ++++++++-
src/plugins/fts/fts-plugin.c | 1 -
src/plugins/fts/fts-user.c | 17 ++++++++++-------
src/plugins/fts/fts-user.h | 2 +-
4 files changed, 19 insertions(+), 10 deletions(-)
diffs (117 lines):
diff -r 9905ebbf8395 -r 6d5240e7d344 src/plugins/fts-lucene/fts-lucene-plugin.c
--- a/src/plugins/fts-lucene/fts-lucene-plugin.c Fri Apr 24 14:03:01 2015 +0300
+++ b/src/plugins/fts-lucene/fts-lucene-plugin.c Fri Apr 24 14:08:39 2015 +0300
@@ -4,6 +4,7 @@
#include "crc32.h"
#include "mail-storage-hooks.h"
#include "lucene-wrapper.h"
+#include "fts-user.h"
#include "fts-lucene-plugin.h"
const char *fts_lucene_plugin_version = DOVECOT_ABI_VERSION;
@@ -94,7 +95,7 @@
static void fts_lucene_mail_user_created(struct mail_user *user)
{
struct fts_lucene_user *fuser;
- const char *env;
+ const char *env, *error;
fuser = p_new(user->pool, struct fts_lucene_user, 1);
env = mail_user_plugin_getenv(user, "fts_lucene");
@@ -105,6 +106,12 @@
/* invalid settings, disabling */
return;
}
+ if (fuser->set.use_libfts) {
+ if (fts_mail_user_create(user, &error) < 0) {
+ i_error("fts_lucene: %s", error);
+ return;
+ }
+ }
MODULE_CONTEXT_SET(user, fts_lucene_user_module, fuser);
}
diff -r 9905ebbf8395 -r 6d5240e7d344 src/plugins/fts/fts-plugin.c
--- a/src/plugins/fts/fts-plugin.c Fri Apr 24 14:03:01 2015 +0300
+++ b/src/plugins/fts/fts-plugin.c Fri Apr 24 14:08:39 2015 +0300
@@ -13,7 +13,6 @@
const char *fts_plugin_version = DOVECOT_ABI_VERSION;
static struct mail_storage_hooks fts_mail_storage_hooks = {
- .mail_user_created = fts_mail_user_created,
.mailbox_list_created = fts_mailbox_list_created,
.mailbox_allocated = fts_mailbox_allocated,
.mail_allocated = fts_mail_allocated
diff -r 9905ebbf8395 -r 6d5240e7d344 src/plugins/fts/fts-user.c
--- a/src/plugins/fts/fts-user.c Fri Apr 24 14:03:01 2015 +0300
+++ b/src/plugins/fts/fts-user.c Fri Apr 24 14:08:39 2015 +0300
@@ -21,14 +21,15 @@
&mail_user_module_register);
static int
-fts_user_init_languages(struct mail_user *user, struct fts_user *fuser)
+fts_user_init_languages(struct mail_user *user, struct fts_user *fuser,
+ const char **error_r)
{
const char *languages, *unknown;
const char *lang_config[3] = {NULL, NULL, NULL};
languages = mail_user_plugin_getenv(user, "fts_languages");
if (languages == NULL) {
- i_error("fts-dovecot: fts_languages setting is missing - disabling");
+ *error_r = "fts_languages setting is missing";
return -1;
}
@@ -38,11 +39,12 @@
lang_config[0] = "fts_language_config";
if (!fts_language_list_add_names(fuser->lang_list, languages, &unknown)) {
- i_error("fts_languages: Unknown language '%s'", unknown);
+ *error_r = t_strdup_printf(
+ "fts_languages: Unknown language '%s'", unknown);
return -1;
}
if (array_count(fts_language_list_get_all(fuser->lang_list)) == 0) {
- i_error("fts-dovecot: fts_languages setting is empty - disabling");
+ *error_r = "fts_languages setting is empty";
return -1;
}
return 0;
@@ -199,7 +201,7 @@
fuser->module_ctx.super.deinit(user);
}
-void fts_mail_user_created(struct mail_user *user)
+int fts_mail_user_create(struct mail_user *user, const char **error_r)
{
struct mail_user_vfuncs *v = user->vlast;
struct fts_user *fuser;
@@ -207,13 +209,14 @@
fuser = p_new(user->pool, struct fts_user, 1);
p_array_init(&fuser->languages, user->pool, 4);
- if (fts_user_init_languages(user, fuser) < 0) {
+ if (fts_user_init_languages(user, fuser, error_r) < 0) {
fts_user_free(fuser);
- return;
+ return -1;
}
fuser->module_ctx.super = *v;
user->vlast = &fuser->module_ctx.super;
v->deinit = fts_mail_user_deinit;
MODULE_CONTEXT_SET(user, fts_user_module, fuser);
+ return 0;
}
diff -r 9905ebbf8395 -r 6d5240e7d344 src/plugins/fts/fts-user.h
--- a/src/plugins/fts/fts-user.h Fri Apr 24 14:03:01 2015 +0300
+++ b/src/plugins/fts/fts-user.h Fri Apr 24 14:08:39 2015 +0300
@@ -17,6 +17,6 @@
const ARRAY_TYPE(fts_user_language) *
fts_user_get_all_languages(struct mail_user *user);
-void fts_mail_user_created(struct mail_user *user);
+int fts_mail_user_create(struct mail_user *user, const char **error_r);
#endif
More information about the dovecot-cvs
mailing list