dovecot-2.0: lazy-expunge: Keep internal namespaces referenced. ...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jul 26 21:11:20 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/bab22fff6d25
changeset: 11902:bab22fff6d25
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jul 26 19:11:13 2010 +0100
description:
lazy-expunge: Keep internal namespaces referenced. Fixes crash with dsync.

diffstat:

 src/plugins/lazy-expunge/lazy-expunge-plugin.c |  20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diffs (48 lines):

diff -r edb8f06c7346 -r bab22fff6d25 src/plugins/lazy-expunge/lazy-expunge-plugin.c
--- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c	Mon Jul 26 19:10:52 2010 +0100
+++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c	Mon Jul 26 19:11:13 2010 +0100
@@ -539,6 +539,7 @@
 			mail_namespace_find_prefix(namespaces, name);
 		if (luser->lazy_ns[i] == NULL)
 			i_fatal("lazy_expunge: Unknown namespace: '%s'", name);
+		mail_namespace_ref(luser->lazy_ns[i]);
 
 		/* we don't want to override these namespaces' expunge/delete
 		   operations. */
@@ -547,18 +548,35 @@
 	}
 	if (i == 0)
 		i_fatal("lazy_expunge: No namespaces defined");
-	for (; i < LAZY_NAMESPACE_COUNT; i++)
+	for (; i < LAZY_NAMESPACE_COUNT; i++) {
 		luser->lazy_ns[i] = luser->lazy_ns[i-1];
+		mail_namespace_ref(luser->lazy_ns[i]);
+	}
+}
+
+static void lazy_expunge_user_deinit(struct mail_user *user)
+{
+	struct lazy_expunge_mail_user *luser = LAZY_EXPUNGE_USER_CONTEXT(user);
+	unsigned int i;
+
+	for (i = 0; i < LAZY_NAMESPACE_COUNT; i++)
+		mail_namespace_unref(&luser->lazy_ns[i]);
+
+	luser->module_ctx.super.deinit(user);
 }
 
 static void lazy_expunge_mail_user_created(struct mail_user *user)
 {
+	struct mail_user_vfuncs *v = user->vlast;
 	struct lazy_expunge_mail_user *luser;
 	const char *env;
 
 	env = mail_user_plugin_getenv(user, "lazy_expunge");
 	if (env != NULL) {
 		luser = p_new(user->pool, struct lazy_expunge_mail_user, 1);
+		luser->module_ctx.super = *v;
+		user->vlast = &luser->module_ctx.super;
+		v->deinit = lazy_expunge_user_deinit;
 		luser->env = env;
 
 		MODULE_CONTEXT_SET(user, lazy_expunge_mail_user_module, luser);


More information about the dovecot-cvs mailing list