dovecot-1.1: next_hook should be called after our hook is finish...

dovecot at dovecot.org dovecot at dovecot.org
Fri Apr 25 01:31:10 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/068f6eefc62b
changeset: 7462:068f6eefc62b
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Apr 25 01:31:05 2008 +0300
description:
next_hook should be called after our hook is finished with its doings, that
way they get executed in the intended order. This should fix some problems
when multiple plugins are used.

diffstat:

10 files changed, 69 insertions(+), 56 deletions(-)
src/plugins/acl/acl-mailbox-list.c             |    8 +++----
src/plugins/acl/acl-storage.c                  |    6 ++---
src/plugins/convert/convert-plugin.c           |   26 ++++++++++++++----------
src/plugins/expire/expire-plugin.c             |    6 ++---
src/plugins/fts/fts-storage.c                  |   22 ++++++++++++--------
src/plugins/lazy-expunge/lazy-expunge-plugin.c |   19 ++++++++++-------
src/plugins/mail-log/mail-log-plugin.c         |   12 +++++------
src/plugins/mbox-snarf/mbox-snarf-plugin.c     |    6 ++---
src/plugins/quota/quota-storage.c              |   14 ++++++------
src/plugins/zlib/zlib-plugin.c                 |    6 ++---

diffs (truncated from 313 to 300 lines):

diff -r bf99bd33d69b -r 068f6eefc62b src/plugins/acl/acl-mailbox-list.c
--- a/src/plugins/acl/acl-mailbox-list.c	Fri Apr 25 01:29:15 2008 +0300
+++ b/src/plugins/acl/acl-mailbox-list.c	Fri Apr 25 01:31:05 2008 +0300
@@ -387,9 +387,6 @@ void acl_mailbox_list_created(struct mai
 	const char *acl_env, *current_username, *owner_username;
 	bool owner = TRUE;
 
-	if (acl_next_hook_mailbox_list_created != NULL)
-		acl_next_hook_mailbox_list_created(list);
-
 	acl_env = getenv("ACL");
 	i_assert(acl_env != NULL);
 
@@ -437,4 +434,7 @@ void acl_mailbox_list_created(struct mai
 	acl_storage_rights_ctx_init(&alist->rights, backend);
 
 	MODULE_CONTEXT_SET(list, acl_mailbox_list_module, alist);
-}
+
+	if (acl_next_hook_mailbox_list_created != NULL)
+		acl_next_hook_mailbox_list_created(list);
+}
diff -r bf99bd33d69b -r 068f6eefc62b src/plugins/acl/acl-storage.c
--- a/src/plugins/acl/acl-storage.c	Fri Apr 25 01:29:15 2008 +0300
+++ b/src/plugins/acl/acl-storage.c	Fri Apr 25 01:31:05 2008 +0300
@@ -160,9 +160,6 @@ void acl_mail_storage_created(struct mai
 	struct acl_mail_storage *astorage;
 	struct acl_backend *backend;
 
-	if (acl_next_hook_mail_storage_created != NULL)
-		acl_next_hook_mail_storage_created(storage);
-
 	astorage = p_new(storage->pool, struct acl_mail_storage, 1);
 	astorage->module_ctx.super = storage->v;
 	storage->v.destroy = acl_storage_destroy;
@@ -173,5 +170,8 @@ void acl_mail_storage_created(struct mai
 	acl_storage_rights_ctx_init(&astorage->rights, backend);
 
 	MODULE_CONTEXT_SET(storage, acl_storage_module, astorage);
+
+	if (acl_next_hook_mail_storage_created != NULL)
+		acl_next_hook_mail_storage_created(storage);
 }
 
diff -r bf99bd33d69b -r 068f6eefc62b src/plugins/convert/convert-plugin.c
--- a/src/plugins/convert/convert-plugin.c	Fri Apr 25 01:29:15 2008 +0300
+++ b/src/plugins/convert/convert-plugin.c	Fri Apr 25 01:31:05 2008 +0300
@@ -12,18 +12,11 @@ static void (*convert_next_hook_mail_nam
 static void (*convert_next_hook_mail_namespaces_created)
 	(struct mail_namespace *namespaces);
 
-static void
-convert_hook_mail_namespaces_created(struct mail_namespace *namespaces)
+static void convert_mail_storage(struct mail_namespace *namespaces,
+				 const char *convert_mail)
 {
-	const char *convert_mail, *str;
+	const char *str;
 	struct convert_settings set;
-
-	if (convert_next_hook_mail_namespaces_created != NULL)
-		convert_next_hook_mail_namespaces_created(namespaces);
-
-	convert_mail = getenv("CONVERT_MAIL");
-	if (convert_mail == NULL)
-		return;
 
 	memset(&set, 0, sizeof(set));
 	set.user = getenv("USER");
@@ -44,6 +37,19 @@ convert_hook_mail_namespaces_created(str
 		i_fatal("Mailbox conversion failed, exiting");
 }
 
+static void
+convert_hook_mail_namespaces_created(struct mail_namespace *namespaces)
+{
+	const char *convert_mail;
+
+	convert_mail = getenv("CONVERT_MAIL");
+	if (convert_mail != NULL)
+		convert_mail_storage(namespaces, convert_mail);
+
+	if (convert_next_hook_mail_namespaces_created != NULL)
+		convert_next_hook_mail_namespaces_created(namespaces);
+}
+
 void convert_plugin_init(void)
 {
 	convert_next_hook_mail_namespaces_created =
diff -r bf99bd33d69b -r 068f6eefc62b src/plugins/expire/expire-plugin.c
--- a/src/plugins/expire/expire-plugin.c	Fri Apr 25 01:29:15 2008 +0300
+++ b/src/plugins/expire/expire-plugin.c	Fri Apr 25 01:31:05 2008 +0300
@@ -271,15 +271,15 @@ static void expire_mail_storage_created(
 {
 	union mail_storage_module_context *xpr_storage;
 
-	if (expire.next_hook_mail_storage_created != NULL)
-		expire.next_hook_mail_storage_created(storage);
-
 	xpr_storage =
 		p_new(storage->pool, union mail_storage_module_context, 1);
 	xpr_storage->super = storage->v;
 	storage->v.mailbox_open = expire_mailbox_open;
 
 	MODULE_CONTEXT_SET_SELF(storage, expire_storage_module, xpr_storage);
+
+	if (expire.next_hook_mail_storage_created != NULL)
+		expire.next_hook_mail_storage_created(storage);
 }
 
 void expire_plugin_init(void)
diff -r bf99bd33d69b -r 068f6eefc62b src/plugins/fts/fts-storage.c
--- a/src/plugins/fts/fts-storage.c	Fri Apr 25 01:29:15 2008 +0300
+++ b/src/plugins/fts/fts-storage.c	Fri Apr 25 01:31:05 2008 +0300
@@ -659,17 +659,9 @@ static int fts_transaction_commit(struct
 	return ret;
 }
 
-void fts_mailbox_opened(struct mailbox *box)
+static void fts_mailbox_init(struct mailbox *box, const char *env)
 {
 	struct fts_mailbox *fbox;
-	const char *env;
-
-	if (fts_next_hook_mailbox_opened != NULL)
-		fts_next_hook_mailbox_opened(box);
-
-	env = getenv("FTS");
-	if (env == NULL)
-		return;
 
 	fbox = i_new(struct fts_mailbox, 1);
 	fbox->env = env;
@@ -686,3 +678,15 @@ void fts_mailbox_opened(struct mailbox *
 
 	MODULE_CONTEXT_SET(box, fts_storage_module, fbox);
 }
+
+void fts_mailbox_opened(struct mailbox *box)
+{
+	const char *env;
+
+	env = getenv("FTS");
+	if (env != NULL)
+		fts_mailbox_init(box, env);
+
+	if (fts_next_hook_mailbox_opened != NULL)
+		fts_next_hook_mailbox_opened(box);
+}
diff -r bf99bd33d69b -r 068f6eefc62b src/plugins/lazy-expunge/lazy-expunge-plugin.c
--- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c	Fri Apr 25 01:29:15 2008 +0300
+++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c	Fri Apr 25 01:31:05 2008 +0300
@@ -472,20 +472,13 @@ lazy_expunge_mailbox_list_delete(struct 
 	return 0;
 }
 
-static void lazy_expunge_mail_storage_created(struct mail_storage *storage)
+static void lazy_expunge_mail_storage_init(struct mail_storage *storage)
 {
 	struct lazy_expunge_mailbox_list *llist =
 		LAZY_EXPUNGE_LIST_CONTEXT(storage->list);
 	struct lazy_expunge_mail_storage *lstorage;
 	const char *const *p;
 	unsigned int i;
-
-	if (lazy_expunge_next_hook_mail_storage_created != NULL)
-		lazy_expunge_next_hook_mail_storage_created(storage);
-
-	/* only maildir supported for now */
-	if (strcmp(storage->name, "maildir") != 0)
-		return;
 
 	/* if this is one of our internal storages, mark it as such before
 	   quota plugin sees it */
@@ -506,6 +499,16 @@ static void lazy_expunge_mail_storage_cr
 	MODULE_CONTEXT_SET(storage, lazy_expunge_mail_storage_module, lstorage);
 }
 
+static void lazy_expunge_mail_storage_created(struct mail_storage *storage)
+{
+	/* only maildir supported for now */
+	if (strcmp(storage->name, "maildir") == 0)
+		lazy_expunge_mail_storage_init(storage);
+
+	if (lazy_expunge_next_hook_mail_storage_created != NULL)
+		lazy_expunge_next_hook_mail_storage_created(storage);
+}
+
 static void lazy_expunge_mailbox_list_created(struct mailbox_list *list)
 {
 	struct lazy_expunge_mailbox_list *llist;
diff -r bf99bd33d69b -r 068f6eefc62b src/plugins/mail-log/mail-log-plugin.c
--- a/src/plugins/mail-log/mail-log-plugin.c	Fri Apr 25 01:29:15 2008 +0300
+++ b/src/plugins/mail-log/mail-log-plugin.c	Fri Apr 25 01:31:05 2008 +0300
@@ -499,22 +499,19 @@ static void mail_log_mail_storage_create
 {
 	union mail_storage_module_context *lstorage;
 
-	if (mail_log_next_hook_mail_storage_created != NULL)
-		mail_log_next_hook_mail_storage_created(storage);
-
 	lstorage = p_new(storage->pool, union mail_storage_module_context, 1);
 	lstorage->super = storage->v;
 	storage->v.mailbox_open = mail_log_mailbox_open;
 
 	MODULE_CONTEXT_SET_SELF(storage, mail_log_storage_module, lstorage);
+
+	if (mail_log_next_hook_mail_storage_created != NULL)
+		mail_log_next_hook_mail_storage_created(storage);
 }
 
 static void mail_log_mailbox_list_created(struct mailbox_list *list)
 {
 	union mailbox_list_module_context *llist;
-
-	if (mail_log_next_hook_mailbox_list_created != NULL)
-		mail_log_next_hook_mailbox_list_created(list);
 
 	llist = p_new(list->pool, union mailbox_list_module_context, 1);
 	llist->super = list->v;
@@ -522,6 +519,9 @@ static void mail_log_mailbox_list_create
 	list->v.rename_mailbox = mail_log_mailbox_list_rename;
 
 	MODULE_CONTEXT_SET_SELF(list, mail_log_mailbox_list_module, llist);
+
+	if (mail_log_next_hook_mailbox_list_created != NULL)
+		mail_log_next_hook_mailbox_list_created(list);
 }
 
 static enum mail_log_field mail_log_parse_fields(const char *str)
diff -r bf99bd33d69b -r 068f6eefc62b src/plugins/mbox-snarf/mbox-snarf-plugin.c
--- a/src/plugins/mbox-snarf/mbox-snarf-plugin.c	Fri Apr 25 01:29:15 2008 +0300
+++ b/src/plugins/mbox-snarf/mbox-snarf-plugin.c	Fri Apr 25 01:31:05 2008 +0300
@@ -164,9 +164,6 @@ static void mbox_snarf_mail_storage_crea
 {
 	struct mbox_snarf_mail_storage *mstorage;
 
-	if (mbox_snarf_next_hook_mail_storage_created != NULL)
-		mbox_snarf_next_hook_mail_storage_created(storage);
-
 	mstorage = p_new(storage->pool, struct mbox_snarf_mail_storage, 1);
 	mstorage->snarf_inbox_path =
 		p_strdup(storage->pool, home_expand(getenv("MBOX_SNARF")));
@@ -174,6 +171,9 @@ static void mbox_snarf_mail_storage_crea
 	storage->v.mailbox_open = mbox_snarf_mailbox_open;
 
 	MODULE_CONTEXT_SET(storage, mbox_snarf_storage_module, mstorage);
+
+	if (mbox_snarf_next_hook_mail_storage_created != NULL)
+		mbox_snarf_next_hook_mail_storage_created(storage);
 }
 
 void mbox_snarf_plugin_init(void)
diff -r bf99bd33d69b -r 068f6eefc62b src/plugins/quota/quota-storage.c
--- a/src/plugins/quota/quota-storage.c	Fri Apr 25 01:29:15 2008 +0300
+++ b/src/plugins/quota/quota-storage.c	Fri Apr 25 01:31:05 2008 +0300
@@ -454,9 +454,6 @@ void quota_mail_storage_created(struct m
 	struct quota_mailbox_list *qlist = QUOTA_LIST_CONTEXT(storage->list);
 	union mail_storage_module_context *qstorage;
 
-	if (quota_next_hook_mail_storage_created != NULL)
-		quota_next_hook_mail_storage_created(storage);
-
 	qlist->storage = storage;
 
 	qstorage = p_new(storage->pool, union mail_storage_module_context, 1);
@@ -471,18 +468,21 @@ void quota_mail_storage_created(struct m
 		/* register to user's quota roots */
 		quota_add_user_storage(quota_set, storage);
 	}
+
+	if (quota_next_hook_mail_storage_created != NULL)
+		quota_next_hook_mail_storage_created(storage);
 }
 
 void quota_mailbox_list_created(struct mailbox_list *list)
 {
 	struct quota_mailbox_list *qlist;
-
-	if (quota_next_hook_mailbox_list_created != NULL)
-		quota_next_hook_mailbox_list_created(list);
 
 	qlist = p_new(list->pool, struct quota_mailbox_list, 1);
 	qlist->module_ctx.super = list->v;
 	list->v.delete_mailbox = quota_mailbox_list_delete;
 
 	MODULE_CONTEXT_SET(list, quota_mailbox_list_module, qlist);
-}
+
+	if (quota_next_hook_mailbox_list_created != NULL)
+		quota_next_hook_mailbox_list_created(list);
+}
diff -r bf99bd33d69b -r 068f6eefc62b src/plugins/zlib/zlib-plugin.c
--- a/src/plugins/zlib/zlib-plugin.c	Fri Apr 25 01:29:15 2008 +0300
+++ b/src/plugins/zlib/zlib-plugin.c	Fri Apr 25 01:31:05 2008 +0300
@@ -140,14 +140,14 @@ static void zlib_mail_storage_created(st
 {
 	union mail_storage_module_context *qstorage;
 
-	if (zlib_next_hook_mail_storage_created != NULL)


More information about the dovecot-cvs mailing list