changeset 8085:bf83aa9c3f4a HEAD

Removed pool parameter from mail_namespaces_init*(). Use mail_user's pool intead.
author Timo Sirainen <tss@iki.fi>
date Tue, 12 Aug 2008 14:54:27 -0400
parents f12f8c1da0bf
children 27940e82901e
files src/deliver/deliver.c src/imap/main.c src/lib-storage/mail-namespace.c src/lib-storage/mail-namespace.h src/plugins/convert/convert-storage.c src/plugins/convert/convert-tool.c src/plugins/expire/expire-tool.c src/pop3/main.c
diffstat 8 files changed, 17 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
 	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 @@
 
 	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",
--- 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 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 @@
 
         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 @@
 	commands_deinit();
         mail_storage_deinit();
 	dict_driver_unregister(&dict_driver_client);
-	pool_unref(&namespace_pool);
 
 	str_free(&capability_string);
 
--- 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 @@
 }
 
 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 @@
 
 	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 @@
 	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 @@
 			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 @@
 			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 @@
 }
 
 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 |
--- 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 @@
 /* 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. */
--- 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 @@
 	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;
--- 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 @@
 
 	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) {
--- 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 @@
 
 	char *user;
 	struct mail_user *mail_user;
-	pool_t namespace_pool;
 	bool testrun;
 };
 
@@ -45,7 +44,7 @@
 	}
 
 	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 @@
 {
 	mail_user_deinit(&ctx->mail_user);
 	i_free_and_null(ctx->user);
-	p_clear(ctx->namespace_pool);
 }
 
 static int
@@ -204,7 +202,6 @@
 	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)
--- 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 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 @@
 		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);