dovecot-2.2: fts: Fixed memory leak at deinit when using multipl...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jun 1 23:41:40 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/77575024f874
changeset: 18792:77575024f874
user: Timo Sirainen <tss at iki.fi>
date: Tue Jun 02 02:39:20 2015 +0300
description:
fts: Fixed memory leak at deinit when using multiple fts plugins at the same time using libfts.
diffstat:
src/plugins/fts-lucene/fts-lucene-plugin.c | 3 ++-
src/plugins/fts-solr/fts-solr-plugin.c | 3 ++-
src/plugins/fts/fts-user.c | 17 ++++++++++++++---
3 files changed, 18 insertions(+), 5 deletions(-)
diffs (67 lines):
diff -r e4f4cbc63b49 -r 77575024f874 src/plugins/fts-lucene/fts-lucene-plugin.c
--- a/src/plugins/fts-lucene/fts-lucene-plugin.c Tue Jun 02 02:26:44 2015 +0300
+++ b/src/plugins/fts-lucene/fts-lucene-plugin.c Tue Jun 02 02:39:20 2015 +0300
@@ -96,7 +96,8 @@
{
struct fts_lucene_user *fuser = FTS_LUCENE_USER_CONTEXT(user);
- fts_mail_user_deinit(user);
+ if (fuser->set.use_libfts)
+ fts_mail_user_deinit(user);
fuser->module_ctx.super.deinit(user);
}
diff -r e4f4cbc63b49 -r 77575024f874 src/plugins/fts-solr/fts-solr-plugin.c
--- a/src/plugins/fts-solr/fts-solr-plugin.c Tue Jun 02 02:26:44 2015 +0300
+++ b/src/plugins/fts-solr/fts-solr-plugin.c Tue Jun 02 02:39:20 2015 +0300
@@ -54,7 +54,8 @@
{
struct fts_solr_user *fuser = FTS_SOLR_USER_CONTEXT(user);
- fts_mail_user_deinit(user);
+ if (fuser->set.use_libfts)
+ fts_mail_user_deinit(user);
fuser->module_ctx.super.deinit(user);
}
diff -r e4f4cbc63b49 -r 77575024f874 src/plugins/fts/fts-user.c
--- a/src/plugins/fts/fts-user.c Tue Jun 02 02:26:44 2015 +0300
+++ b/src/plugins/fts/fts-user.c Tue Jun 02 02:39:20 2015 +0300
@@ -16,6 +16,7 @@
struct fts_user {
union mail_user_module_context module_ctx;
+ int refcount;
struct fts_language_list *lang_list;
struct fts_tokenizer *index_tokenizer, *search_tokenizer;
@@ -335,9 +336,16 @@
int fts_mail_user_init(struct mail_user *user, const char **error_r)
{
- struct fts_user *fuser;
+ struct fts_user *fuser = FTS_USER_CONTEXT(user);
+
+ if (fuser != NULL) {
+ /* multiple fts plugins are loaded */
+ fuser->refcount++;
+ return 0;
+ }
fuser = p_new(user->pool, struct fts_user, 1);
+ fuser->refcount = 1;
p_array_init(&fuser->languages, user->pool, 4);
if (fts_user_init_languages(user, fuser, error_r) < 0) {
@@ -358,6 +366,9 @@
{
struct fts_user *fuser = FTS_USER_CONTEXT(user);
- if (fuser != NULL)
- fts_user_free(fuser);
+ if (fuser != NULL) {
+ i_assert(fuser->refcount > 0);
+ if (--fuser->refcount == 0)
+ fts_user_free(fuser);
+ }
}
More information about the dovecot-cvs
mailing list