changeset 22042:ba158fa10ff8

lib-storage: add a mail user pre-deinit vfunc This allows plugins to perform checks right before the deinit call.
author Josef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
date Fri, 12 May 2017 12:44:27 +0300
parents 21fab4826117
children 81e013b3207d
files src/lib-storage/mail-user.c src/lib-storage/mail-user.h
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/mail-user.c	Thu May 04 19:59:41 2017 +0300
+++ b/src/lib-storage/mail-user.c	Fri May 12 12:44:27 2017 +0300
@@ -40,6 +40,10 @@
 		mail_storage_service_user_unref(&user->_service_user);
 }
 
+static void mail_user_deinit_pre_base(struct mail_user *user ATTR_UNUSED)
+{
+}
+
 static void mail_user_stats_fill_base(struct mail_user *user ATTR_UNUSED,
 				      struct stats *stats ATTR_UNUSED)
 {
@@ -73,6 +77,7 @@
 		i_panic("Settings check unexpectedly failed: %s", error);
 
 	user->v.deinit = mail_user_deinit_base;
+	user->v.deinit_pre = mail_user_deinit_pre_base;
 	user->v.stats_fill = mail_user_stats_fill_base;
 	p_array_init(&user->module_contexts, user->pool, 5);
 	return user;
@@ -191,8 +196,9 @@
 
 	user->deinitializing = TRUE;
 
-	/* call deinit() with refcount=1, otherwise we may assert-crash in
-	   mail_user_ref() that is called by some deinit() handler. */
+	/* call deinit() and deinit_pre() with refcount=1, otherwise we may
+	   assert-crash in mail_user_ref() that is called by some handlers. */
+	user->v.deinit_pre(user);
 	user->v.deinit(user);
 	i_assert(user->refcount == 1);
 	pool_unref(&user->pool);
--- a/src/lib-storage/mail-user.h	Thu May 04 19:59:41 2017 +0300
+++ b/src/lib-storage/mail-user.h	Fri May 12 12:44:27 2017 +0300
@@ -12,6 +12,7 @@
 
 struct mail_user_vfuncs {
 	void (*deinit)(struct mail_user *user);
+	void (*deinit_pre)(struct mail_user *user);
 	void (*stats_fill)(struct mail_user *user, struct stats *stats);
 };