dovecot-1.2: Removed pool parameter from mail_namespaces_init*()...

dovecot at dovecot.org dovecot at dovecot.org
Tue Aug 12 21:54:35 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/bf83aa9c3f4a
changeset: 8085:bf83aa9c3f4a
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Aug 12 14:54:27 2008 -0400
description:
Removed pool parameter from mail_namespaces_init*(). Use mail_user's pool intead.

diffstat:

8 files changed, 17 insertions(+), 28 deletions(-)
src/deliver/deliver.c                 |    6 ++----
src/imap/main.c                       |    5 +----
src/lib-storage/mail-namespace.c      |   16 ++++++++--------
src/lib-storage/mail-namespace.h      |    5 ++---
src/plugins/convert/convert-storage.c |    2 +-
src/plugins/convert/convert-tool.c    |    2 +-
src/plugins/expire/expire-tool.c      |    5 +----
src/pop3/main.c                       |    4 +---

diffs (225 lines):

diff -r f12f8c1da0bf -r bf83aa9c3f4a src/deliver/deliver.c
--- a/src/deliver/deliver.c	Tue Aug 12 12:42:28 2008 -0400
+++ b/src/deliver/deliver.c	Tue Aug 12 14:54:27 2008 -0400
@@ -787,7 +787,6 @@ int main(int argc, char *argv[])
 	struct mailbox_header_lookup_ctx *headers_ctx;
 	struct mail *mail;
 	uid_t process_euid;
-	pool_t namespace_pool;
 	bool stderr_rejection = FALSE;
 	bool keep_environment = FALSE;
 	bool user_auth = FALSE;
@@ -1002,14 +1001,13 @@ int main(int argc, char *argv[])
 
 	module_dir_init(modules);
 
-	namespace_pool = pool_alloconly_create("namespaces", 1024);
 	mail_user = mail_user_init(user, home);
-	if (mail_namespaces_init(namespace_pool, mail_user) < 0)
+	if (mail_namespaces_init(mail_user) < 0)
 		i_fatal("Namespace initialization failed");
 
 	/* create a separate mail user for the internal namespace */
 	raw_mail_user = mail_user_init(user, NULL);
-	raw_ns = mail_namespaces_init_empty(namespace_pool, raw_mail_user);
+	raw_ns = mail_namespaces_init_empty(raw_mail_user);
 	raw_ns->flags |= NAMESPACE_FLAG_INTERNAL;
 
 	if (mail_storage_create(raw_ns, "raw", "/tmp",
diff -r f12f8c1da0bf -r bf83aa9c3f4a src/imap/main.c
--- a/src/imap/main.c	Tue Aug 12 12:42:28 2008 -0400
+++ b/src/imap/main.c	Tue Aug 12 14:54:27 2008 -0400
@@ -47,7 +47,6 @@ static struct io *log_io = NULL;
 static struct io *log_io = NULL;
 static struct module *modules = NULL;
 static char log_prefix[128]; /* syslog() needs this to be permanent */
-static pool_t namespace_pool;
 
 void (*hook_client_created)(struct client **client) = NULL;
 
@@ -229,9 +228,8 @@ static void main_init(void)
 
         parse_workarounds();
 
-	namespace_pool = pool_alloconly_create("namespaces", 1024);
 	user = mail_user_init(username, home);
-	if (mail_namespaces_init(namespace_pool, user) < 0)
+	if (mail_namespaces_init(user) < 0)
 		i_fatal("Namespace initialization failed");
 	client = client_create(0, 1, user);
 
@@ -275,7 +273,6 @@ static void main_deinit(void)
 	commands_deinit();
         mail_storage_deinit();
 	dict_driver_unregister(&dict_driver_client);
-	pool_unref(&namespace_pool);
 
 	str_free(&capability_string);
 
diff -r f12f8c1da0bf -r bf83aa9c3f4a src/lib-storage/mail-namespace.c
--- a/src/lib-storage/mail-namespace.c	Tue Aug 12 12:42:28 2008 -0400
+++ b/src/lib-storage/mail-namespace.c	Tue Aug 12 14:54:27 2008 -0400
@@ -28,14 +28,14 @@ void mail_namespace_init_storage(struct 
 }
 
 static struct mail_namespace *
-namespace_add_env(pool_t pool, const char *data, unsigned int num,
+namespace_add_env(const char *data, unsigned int num,
 		  struct mail_user *user, enum mail_storage_flags flags,
 		  enum file_lock_method lock_method)
 {
         struct mail_namespace *ns;
 	const char *sep, *type, *prefix, *error;
 
-	ns = p_new(pool, struct mail_namespace, 1);
+	ns = p_new(user->pool, struct mail_namespace, 1);
 
 	sep = getenv(t_strdup_printf("NAMESPACE_%u_SEP", num));
 	type = getenv(t_strdup_printf("NAMESPACE_%u_TYPE", num));
@@ -76,7 +76,7 @@ namespace_add_env(pool_t pool, const cha
 
 	if (sep != NULL)
 		ns->sep = *sep;
-	ns->prefix = p_strdup(pool, prefix);
+	ns->prefix = p_strdup(user->pool, prefix);
 	ns->user = user;
 
 	if (mail_storage_create(ns, NULL, data, flags, lock_method,
@@ -178,7 +178,7 @@ namespaces_sort(struct mail_namespace *s
 	return dest;
 }
 
-int mail_namespaces_init(pool_t pool, struct mail_user *user)
+int mail_namespaces_init(struct mail_user *user)
 {
 	struct mail_namespace *namespaces, *ns, **ns_p;
 	enum mail_storage_flags flags;
@@ -199,7 +199,7 @@ int mail_namespaces_init(pool_t pool, st
 			break;
 
 		T_BEGIN {
-			*ns_p = namespace_add_env(pool, data, i, user, flags,
+			*ns_p = namespace_add_env(data, i, user, flags,
 						  lock_method);
 		} T_END;
 
@@ -232,7 +232,7 @@ int mail_namespaces_init(pool_t pool, st
 			mail = t_strconcat("maildir:", mail, NULL);
 	}
 
-	ns = p_new(pool, struct mail_namespace, 1);
+	ns = p_new(user->pool, struct mail_namespace, 1);
 	ns->type = NAMESPACE_PRIVATE;
 	ns->flags = NAMESPACE_FLAG_INBOX | NAMESPACE_FLAG_LIST |
 		NAMESPACE_FLAG_SUBSCRIPTIONS;
@@ -260,11 +260,11 @@ int mail_namespaces_init(pool_t pool, st
 }
 
 struct mail_namespace *
-mail_namespaces_init_empty(pool_t pool, struct mail_user *user)
+mail_namespaces_init_empty(struct mail_user *user)
 {
 	struct mail_namespace *ns;
 
-	ns = p_new(pool, struct mail_namespace, 1);
+	ns = p_new(user->pool, struct mail_namespace, 1);
 	ns->user = user;
 	ns->prefix = "";
 	ns->flags = NAMESPACE_FLAG_INBOX | NAMESPACE_FLAG_LIST |
diff -r f12f8c1da0bf -r bf83aa9c3f4a src/lib-storage/mail-namespace.h
--- a/src/lib-storage/mail-namespace.h	Tue Aug 12 12:42:28 2008 -0400
+++ b/src/lib-storage/mail-namespace.h	Tue Aug 12 14:54:27 2008 -0400
@@ -43,9 +43,8 @@ struct mail_namespace {
 /* Called after namespaces has been created */
 extern void (*hook_mail_namespaces_created)(struct mail_namespace *namespaces);
 
-int mail_namespaces_init(pool_t pool, struct mail_user *user);
-struct mail_namespace *
-mail_namespaces_init_empty(pool_t pool, struct mail_user *user);
+int mail_namespaces_init(struct mail_user *user);
+struct mail_namespace *mail_namespaces_init_empty(struct mail_user *user);
 void mail_namespaces_deinit(struct mail_namespace **namespaces);
 
 /* Update hierarchy separators in given name to real_sep characters. */
diff -r f12f8c1da0bf -r bf83aa9c3f4a src/plugins/convert/convert-storage.c
--- a/src/plugins/convert/convert-storage.c	Tue Aug 12 12:42:28 2008 -0400
+++ b/src/plugins/convert/convert-storage.c	Tue Aug 12 14:54:27 2008 -0400
@@ -400,7 +400,7 @@ int convert_storage(const char *source_d
 	const char *path, *error;
 	int ret;
 
-	source_ns = mail_namespaces_init_empty(pool_datastack_create(), user);
+	source_ns = mail_namespaces_init_empty(user);
 	dest_inbox_ns = mail_namespace_find_inbox(dest_namespaces);
 	src_flags = dest_inbox_ns->storage->flags;
 	lock_method = dest_inbox_ns->storage->lock_method;
diff -r f12f8c1da0bf -r bf83aa9c3f4a src/plugins/convert/convert-tool.c
--- a/src/plugins/convert/convert-tool.c	Tue Aug 12 12:42:28 2008 -0400
+++ b/src/plugins/convert/convert-tool.c	Tue Aug 12 14:54:27 2008 -0400
@@ -49,7 +49,7 @@ int main(int argc, const char *argv[])
 
 	mail_storage_parse_env(&dest_flags, &lock_method);
 	user = mail_user_init(argv[1], argv[2]);
-	dest_ns = mail_namespaces_init_empty(pool_datastack_create(), user);
+	dest_ns = mail_namespaces_init_empty(user);
 
 	if (mail_storage_create(dest_ns, NULL, argv[4],
 				dest_flags, lock_method, &error) < 0) {
diff -r f12f8c1da0bf -r bf83aa9c3f4a src/plugins/expire/expire-tool.c
--- a/src/plugins/expire/expire-tool.c	Tue Aug 12 12:42:28 2008 -0400
+++ b/src/plugins/expire/expire-tool.c	Tue Aug 12 14:54:27 2008 -0400
@@ -27,7 +27,6 @@ struct expire_context {
 
 	char *user;
 	struct mail_user *mail_user;
-	pool_t namespace_pool;
 	bool testrun;
 };
 
@@ -45,7 +44,7 @@ static int user_init(struct expire_conte
 	}
 
 	ctx->mail_user = mail_user_init(user, getenv("HOME"));
-	if (mail_namespaces_init(ctx->namespace_pool, ctx->mail_user) < 0)
+	if (mail_namespaces_init(ctx->mail_user) < 0)
 		return -1;
 	return 1;
 }
@@ -54,7 +53,6 @@ static void user_deinit(struct expire_co
 {
 	mail_user_deinit(&ctx->mail_user);
 	i_free_and_null(ctx->user);
-	p_clear(ctx->namespace_pool);
 }
 
 static int
@@ -204,7 +202,6 @@ static void expire_run(bool testrun)
 	memset(&ctx, 0, sizeof(ctx));
 	ctx.testrun = testrun;
 	ctx.auth_conn = auth_connection_init(auth_socket);
-	ctx.namespace_pool = pool_alloconly_create("namespaces", 1024);
 	env = expire_env_init(getenv("EXPIRE"), getenv("EXPIRE_ALTMOVE"));
 	dict = dict_init(getenv("EXPIRE_DICT"), DICT_DATA_TYPE_UINT32, "");
 	if (dict == NULL)
diff -r f12f8c1da0bf -r bf83aa9c3f4a src/pop3/main.c
--- a/src/pop3/main.c	Tue Aug 12 12:42:28 2008 -0400
+++ b/src/pop3/main.c	Tue Aug 12 14:54:27 2008 -0400
@@ -41,7 +41,6 @@ void (*hook_client_created)(struct clien
 void (*hook_client_created)(struct client **client) = NULL;
 
 static struct module *modules = NULL;
-static pool_t namespace_pool;
 static char log_prefix[128]; /* syslog() needs this to be permanent */
 static struct io *log_io = NULL;
 
@@ -230,9 +229,8 @@ static bool main_init(void)
 		i_fatal("pop3_uidl_format setting doesn't contain any "
 			"%% variables.");
 
-	namespace_pool = pool_alloconly_create("namespaces", 1024);
 	user = mail_user_init(getenv("USER"), getenv("HOME"));
-	if (mail_namespaces_init(namespace_pool, user) < 0)
+	if (mail_namespaces_init(user) < 0)
 		i_fatal("Namespace initialization failed");
 
 	client = client_create(0, 1, user);


More information about the dovecot-cvs mailing list