dovecot-2.2: fts: Fixed infinite looping at deinit.

dovecot at dovecot.org dovecot at dovecot.org
Fri Apr 24 13:05:44 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/008632bdfd2c
changeset: 18479:008632bdfd2c
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Apr 24 16:03:51 2015 +0300
description:
fts: Fixed infinite looping at deinit.
fts_mail_user_deinit() was calling itself. Now the fts backend is
responsible for calling it at deinit.

diffstat:

 src/plugins/fts-lucene/fts-lucene-plugin.c |  15 ++++++++++++++-
 src/plugins/fts-solr/fts-solr-plugin.c     |  14 +++++++++++++-
 src/plugins/fts/fts-user.c                 |  22 ++++++++--------------
 src/plugins/fts/fts-user.h                 |   3 ++-
 4 files changed, 37 insertions(+), 17 deletions(-)

diffs (128 lines):

diff -r 17b93a5ae095 -r 008632bdfd2c src/plugins/fts-lucene/fts-lucene-plugin.c
--- a/src/plugins/fts-lucene/fts-lucene-plugin.c	Fri Apr 24 15:45:42 2015 +0300
+++ b/src/plugins/fts-lucene/fts-lucene-plugin.c	Fri Apr 24 16:03:51 2015 +0300
@@ -92,8 +92,17 @@
 	return crc;
 }
 
+static void fts_lucene_mail_user_deinit(struct mail_user *user)
+{
+	struct fts_lucene_user *fuser = FTS_LUCENE_USER_CONTEXT(user);
+
+	fts_mail_user_deinit(user);
+	fuser->module_ctx.super.deinit(user);
+}
+
 static void fts_lucene_mail_user_created(struct mail_user *user)
 {
+	struct mail_user_vfuncs *v = user->vlast;
 	struct fts_lucene_user *fuser;
 	const char *env, *error;
 
@@ -107,11 +116,15 @@
 		return;
 	}
 	if (fuser->set.use_libfts) {
-		if (fts_mail_user_create(user, &error) < 0) {
+		if (fts_mail_user_init(user, &error) < 0) {
 			i_error("fts_lucene: %s", error);
 			return;
 		}
 	}
+
+	fuser->module_ctx.super = *v;
+	user->vlast = &fuser->module_ctx.super;
+	v->deinit = fts_lucene_mail_user_deinit;
 	MODULE_CONTEXT_SET(user, fts_lucene_user_module, fuser);
 }
 
diff -r 17b93a5ae095 -r 008632bdfd2c src/plugins/fts-solr/fts-solr-plugin.c
--- a/src/plugins/fts-solr/fts-solr-plugin.c	Fri Apr 24 15:45:42 2015 +0300
+++ b/src/plugins/fts-solr/fts-solr-plugin.c	Fri Apr 24 16:03:51 2015 +0300
@@ -50,8 +50,17 @@
 	return 0;
 }
 
+static void fts_solr_mail_user_deinit(struct mail_user *user)
+{
+	struct fts_solr_user *fuser = FTS_SOLR_USER_CONTEXT(user);
+
+	fts_mail_user_deinit(user);
+	fuser->module_ctx.super.deinit(user);
+}
+
 static void fts_solr_mail_user_create(struct mail_user *user, const char *env)
 {
+	struct mail_user_vfuncs *v = user->vlast;
 	struct fts_solr_user *fuser;
 	const char *error;
 
@@ -61,12 +70,15 @@
 		return;
 	}
 	if (fuser->set.use_libfts) {
-		if (fts_mail_user_create(user, &error) < 0) {
+		if (fts_mail_user_init(user, &error) < 0) {
 			i_error("fts-solr: %s", error);
 			return;
 		}
 	}
 
+	fuser->module_ctx.super = *v;
+	user->vlast = &fuser->module_ctx.super;
+	v->deinit = fts_solr_mail_user_deinit;
 	MODULE_CONTEXT_SET(user, fts_solr_user_module, fuser);
 }
 
diff -r 17b93a5ae095 -r 008632bdfd2c src/plugins/fts/fts-user.c
--- a/src/plugins/fts/fts-user.c	Fri Apr 24 15:45:42 2015 +0300
+++ b/src/plugins/fts/fts-user.c	Fri Apr 24 16:03:51 2015 +0300
@@ -193,17 +193,8 @@
 	}
 }
 
-static void fts_mail_user_deinit(struct mail_user *user)
+int fts_mail_user_init(struct mail_user *user, const char **error_r)
 {
-	struct fts_user *fuser = FTS_USER_CONTEXT(user);
-
-	fts_user_free(fuser);
-	fuser->module_ctx.super.deinit(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;
 
 	fuser = p_new(user->pool, struct fts_user, 1);
@@ -213,10 +204,13 @@
 		fts_user_free(fuser);
 		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;
 }
+
+void fts_mail_user_deinit(struct mail_user *user)
+{
+	struct fts_user *fuser = FTS_USER_CONTEXT(user);
+
+	fts_user_free(fuser);
+}
diff -r 17b93a5ae095 -r 008632bdfd2c src/plugins/fts/fts-user.h
--- a/src/plugins/fts/fts-user.h	Fri Apr 24 15:45:42 2015 +0300
+++ b/src/plugins/fts/fts-user.h	Fri Apr 24 16:03:51 2015 +0300
@@ -17,6 +17,7 @@
 const ARRAY_TYPE(fts_user_language) *
 fts_user_get_all_languages(struct mail_user *user);
 
-int fts_mail_user_create(struct mail_user *user, const char **error_r);
+int fts_mail_user_init(struct mail_user *user, const char **error_r);
+void fts_mail_user_deinit(struct mail_user *user);
 
 #endif


More information about the dovecot-cvs mailing list