dovecot-2.0: lib-storage: Added mailbox.free() method. Use it in...

dovecot at dovecot.org dovecot at dovecot.org
Mon Feb 15 03:07:22 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/e8fc01d03aea
changeset: 10718:e8fc01d03aea
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Feb 15 02:54:32 2010 +0200
description:
lib-storage: Added mailbox.free() method. Use it instead of close() where necessary.

diffstat:

 src/lib-storage/index/cydir/cydir-storage.c       |   1 +
 src/lib-storage/index/dbox-multi/mdbox-storage.c  |   1 +
 src/lib-storage/index/dbox-single/sdbox-storage.c |   1 +
 src/lib-storage/index/index-storage.c             |   3 ++-
 src/lib-storage/index/index-thread-private.h      |   2 +-
 src/lib-storage/index/index-thread.c              |  16 ++++++++++++----
 src/lib-storage/index/maildir/maildir-storage.c   |   6 ++++--
 src/lib-storage/index/mbox/mbox-storage.c         |   1 +
 src/lib-storage/index/raw/raw-storage.c           |   1 +
 src/lib-storage/mail-storage-private.h            |   1 +
 src/lib-storage/mail-storage.c                    |   3 +++
 src/lib-storage/test-mailbox.c                    |   1 +
 src/plugins/acl/acl-mailbox.c                     |   6 +++---
 src/plugins/fts/fts-storage.c                     |   6 +++---
 src/plugins/quota/quota-storage.c                 |   6 +++---
 src/plugins/virtual/virtual-storage.c             |   1 +
 16 files changed, 39 insertions(+), 17 deletions(-)

diffs (288 lines):

diff -r 0bcb415c7a71 -r e8fc01d03aea src/lib-storage/index/cydir/cydir-storage.c
--- a/src/lib-storage/index/cydir/cydir-storage.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/lib-storage/index/cydir/cydir-storage.c	Mon Feb 15 02:54:32 2010 +0200
@@ -140,6 +140,7 @@
 		index_storage_mailbox_enable,
 		cydir_mailbox_open,
 		index_storage_mailbox_close,
+		NULL,
 		cydir_mailbox_create,
 		index_storage_mailbox_update,
 		index_storage_mailbox_delete,
diff -r 0bcb415c7a71 -r e8fc01d03aea src/lib-storage/index/dbox-multi/mdbox-storage.c
--- a/src/lib-storage/index/dbox-multi/mdbox-storage.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c	Mon Feb 15 02:54:32 2010 +0200
@@ -327,6 +327,7 @@
 		index_storage_mailbox_enable,
 		dbox_mailbox_open,
 		index_storage_mailbox_close,
+		NULL,
 		dbox_mailbox_create,
 		mdbox_mailbox_update,
 		mdbox_mailbox_delete,
diff -r 0bcb415c7a71 -r e8fc01d03aea src/lib-storage/index/dbox-single/sdbox-storage.c
--- a/src/lib-storage/index/dbox-single/sdbox-storage.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/lib-storage/index/dbox-single/sdbox-storage.c	Mon Feb 15 02:54:32 2010 +0200
@@ -217,6 +217,7 @@
 		index_storage_mailbox_enable,
 		dbox_mailbox_open,
 		index_storage_mailbox_close,
+		NULL,
 		dbox_mailbox_create,
 		dbox_mailbox_update,
 		index_storage_mailbox_delete,
diff -r 0bcb415c7a71 -r e8fc01d03aea src/lib-storage/index/index-storage.c
--- a/src/lib-storage/index/index-storage.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/lib-storage/index/index-storage.c	Mon Feb 15 02:54:32 2010 +0200
@@ -243,7 +243,6 @@
 
 	box->opened = TRUE;
 
-	index_thread_mailbox_opened(box);
 	if (hook_mailbox_opened != NULL)
 		hook_mailbox_opened(box);
 
@@ -291,6 +290,8 @@
 	mail_index_set_permissions(box->index, box->file_create_mode,
 				   box->file_create_gid,
 				   box->file_create_gid_origin);
+
+	index_thread_mailbox_allocated(box);
 }
 
 int index_storage_mailbox_enable(struct mailbox *box,
diff -r 0bcb415c7a71 -r e8fc01d03aea src/lib-storage/index/index-thread-private.h
--- a/src/lib-storage/index/index-thread-private.h	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/lib-storage/index/index-thread-private.h	Mon Feb 15 02:54:32 2010 +0200
@@ -77,6 +77,6 @@
 			      enum mail_thread_type thread_type,
 			      bool return_seqs);
 
-void index_thread_mailbox_opened(struct mailbox *box);
+void index_thread_mailbox_allocated(struct mailbox *box);
 
 #endif
diff -r 0bcb415c7a71 -r e8fc01d03aea src/lib-storage/index/index-thread.c
--- a/src/lib-storage/index/index-thread.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/lib-storage/index/index-thread.c	Mon Feb 15 02:54:32 2010 +0200
@@ -622,23 +622,31 @@
 
 	if (tbox->strmap_view != NULL)
 		mail_index_strmap_view_close(&tbox->strmap_view);
-	mail_index_strmap_deinit(&tbox->strmap);
 	if (tbox->cache->search_result != NULL)
 		mailbox_search_result_free(&tbox->cache->search_result);
+	tbox->module_ctx.super.close(box);
+}
+
+static void mail_thread_mailbox_free(struct mailbox *box)
+{
+	struct mail_thread_mailbox *tbox = MAIL_THREAD_CONTEXT(box);
+
+	mail_index_strmap_deinit(&tbox->strmap);
+	tbox->module_ctx.super.free(box);
+
 	array_free(&tbox->cache->thread_nodes);
 	i_free(tbox->cache);
-
-	tbox->module_ctx.super.close(box);
 	i_free(tbox);
 }
 
-void index_thread_mailbox_opened(struct mailbox *box)
+void index_thread_mailbox_allocated(struct mailbox *box)
 {
 	struct mail_thread_mailbox *tbox;
 
 	tbox = i_new(struct mail_thread_mailbox, 1);
 	tbox->module_ctx.super = box->v;
 	box->v.close = mail_thread_mailbox_close;
+	box->v.free = mail_thread_mailbox_free;
 
 	tbox->strmap = mail_index_strmap_init(box->index,
 					      MAIL_THREAD_INDEX_SUFFIX);
diff -r 0bcb415c7a71 -r e8fc01d03aea src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Mon Feb 15 02:54:32 2010 +0200
@@ -290,8 +290,6 @@
 	mbox->maildir_ext_id =
 		mail_index_ext_register(mbox->box.index, "maildir",
 					sizeof(mbox->maildir_hdr), 0, 0);
-	mbox->uidlist = maildir_uidlist_init(mbox);
-	mbox->keywords = maildir_keywords_init(mbox);
 	return &mbox->box;
 }
 
@@ -301,6 +299,9 @@
 	struct stat st;
 	const char *shared_path;
 
+	mbox->uidlist = maildir_uidlist_init(mbox);
+	mbox->keywords = maildir_keywords_init(mbox);
+
 	shared_path = t_strconcat(box->path, "/dovecot-shared", NULL);
 	if (stat(shared_path, &st) == 0)
 		box->private_flags_mask = MAIL_SEEN;
@@ -578,6 +579,7 @@
 		index_storage_mailbox_enable,
 		maildir_mailbox_open,
 		maildir_mailbox_close,
+		NULL,
 		maildir_mailbox_create,
 		maildir_mailbox_update,
 		index_storage_mailbox_delete,
diff -r 0bcb415c7a71 -r e8fc01d03aea src/lib-storage/index/mbox/mbox-storage.c
--- a/src/lib-storage/index/mbox/mbox-storage.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/lib-storage/index/mbox/mbox-storage.c	Mon Feb 15 02:54:32 2010 +0200
@@ -693,6 +693,7 @@
 		index_storage_mailbox_enable,
 		mbox_mailbox_open,
 		mbox_mailbox_close,
+		NULL,
 		mbox_mailbox_create,
 		mbox_mailbox_update,
 		index_storage_mailbox_delete,
diff -r 0bcb415c7a71 -r e8fc01d03aea src/lib-storage/index/raw/raw-storage.c
--- a/src/lib-storage/index/raw/raw-storage.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/lib-storage/index/raw/raw-storage.c	Mon Feb 15 02:54:32 2010 +0200
@@ -134,6 +134,7 @@
 		index_storage_mailbox_enable,
 		raw_mailbox_open,
 		index_storage_mailbox_close,
+		NULL,
 		raw_mailbox_create,
 		raw_mailbox_update,
 		index_storage_mailbox_delete,
diff -r 0bcb415c7a71 -r e8fc01d03aea src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/lib-storage/mail-storage-private.h	Mon Feb 15 02:54:32 2010 +0200
@@ -93,6 +93,7 @@
 	int (*enable)(struct mailbox *box, enum mailbox_feature features);
 	int (*open)(struct mailbox *box);
 	void (*close)(struct mailbox *box);
+	void (*free)(struct mailbox *box);
 
 	int (*create)(struct mailbox *box, const struct mailbox_update *update,
 		      bool directory);
diff -r 0bcb415c7a71 -r e8fc01d03aea src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/lib-storage/mail-storage.c	Mon Feb 15 02:54:32 2010 +0200
@@ -580,6 +580,9 @@
 	*_box = NULL;
 
 	mailbox_close(box);
+
+	if (box->v.free != NULL)
+		box->v.free(box);
 	mail_index_alloc_cache_unref(&box->index);
 	pool_unref(&box->pool);
 }
diff -r 0bcb415c7a71 -r e8fc01d03aea src/lib-storage/test-mailbox.c
--- a/src/lib-storage/test-mailbox.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/lib-storage/test-mailbox.c	Mon Feb 15 02:54:32 2010 +0200
@@ -322,6 +322,7 @@
 		test_mailbox_enable,
 		test_mailbox_open,
 		test_mailbox_close,
+		NULL,
 		test_mailbox_create,
 		test_mailbox_update,
 		test_mailbox_delete,
diff -r 0bcb415c7a71 -r e8fc01d03aea src/plugins/acl/acl-mailbox.c
--- a/src/plugins/acl/acl-mailbox.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/plugins/acl/acl-mailbox.c	Mon Feb 15 02:54:32 2010 +0200
@@ -97,12 +97,12 @@
 	return acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE) > 0;
 }
 
-static void acl_mailbox_close(struct mailbox *box)
+static void acl_mailbox_free(struct mailbox *box)
 {
 	struct acl_mailbox *abox = ACL_CONTEXT(box);
 
 	acl_object_deinit(&abox->aclobj);
-	abox->module_ctx.super.close(box);
+	abox->module_ctx.super.free(box);
 }
 
 static void acl_mailbox_copy_acls_from_parent(struct mailbox *box)
@@ -518,7 +518,7 @@
 		box->v.is_readonly = acl_is_readonly;
 		box->v.allow_new_keywords = acl_allow_new_keywords;
 		box->v.open = acl_mailbox_open;
-		box->v.close = acl_mailbox_close;
+		box->v.free = acl_mailbox_free;
 		box->v.create = acl_mailbox_create;
 		box->v.update = acl_mailbox_update;
 		box->v.delete = acl_mailbox_delete;
diff -r 0bcb415c7a71 -r e8fc01d03aea src/plugins/fts/fts-storage.c
--- a/src/plugins/fts/fts-storage.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/plugins/fts/fts-storage.c	Mon Feb 15 02:54:32 2010 +0200
@@ -59,7 +59,7 @@
 				  &mail_storage_module_register);
 static MODULE_CONTEXT_DEFINE_INIT(fts_mail_module, &mail_module_register);
 
-static void fts_mailbox_close(struct mailbox *box)
+static void fts_mailbox_free(struct mailbox *box)
 {
 	struct fts_mailbox *fbox = FTS_CONTEXT(box);
 
@@ -68,7 +68,7 @@
 	if (fbox->backend_fast != NULL)
 		fts_backend_deinit(&fbox->backend_fast);
 
-	fbox->module_ctx.super.close(box);
+	fbox->module_ctx.super.free(box);
 	i_free(fbox);
 }
 
@@ -1028,7 +1028,7 @@
 	fbox->virtual = strcmp(box->storage->name, "virtual") == 0;
 	fbox->env = env;
 	fbox->module_ctx.super = box->v;
-	box->v.close = fts_mailbox_close;
+	box->v.free = fts_mailbox_free;
 	box->v.search_init = fts_mailbox_search_init;
 	box->v.search_next_nonblock = fts_mailbox_search_next_nonblock;
 	box->v.search_next_update_seq = fbox->virtual ?
diff -r 0bcb415c7a71 -r e8fc01d03aea src/plugins/quota/quota-storage.c
--- a/src/plugins/quota/quota-storage.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/plugins/quota/quota-storage.c	Mon Feb 15 02:54:32 2010 +0200
@@ -373,7 +373,7 @@
 	return qbox->module_ctx.super.delete(box);
 }
 
-static void quota_mailbox_close(struct mailbox *box)
+static void quota_mailbox_free(struct mailbox *box)
 {
 	struct quota_mailbox *qbox = QUOTA_CONTEXT(box);
 
@@ -384,7 +384,7 @@
 	i_assert(qbox->expunge_qt == NULL ||
 		 qbox->expunge_qt->tmp_mail == NULL);
 
-	qbox->module_ctx.super.close(box);
+	qbox->module_ctx.super.free(box);
 }
 
 void quota_mailbox_allocated(struct mailbox *box)
@@ -407,7 +407,7 @@
 	box->v.sync_notify = quota_mailbox_sync_notify;
 	box->v.sync_deinit = quota_mailbox_sync_deinit;
 	box->v.delete = quota_mailbox_delete;
-	box->v.close = quota_mailbox_close;
+	box->v.free = quota_mailbox_free;
 	MODULE_CONTEXT_SET(box, quota_storage_module, qbox);
 }
 
diff -r 0bcb415c7a71 -r e8fc01d03aea src/plugins/virtual/virtual-storage.c
--- a/src/plugins/virtual/virtual-storage.c	Mon Feb 15 02:13:14 2010 +0200
+++ b/src/plugins/virtual/virtual-storage.c	Mon Feb 15 02:54:32 2010 +0200
@@ -445,6 +445,7 @@
 		index_storage_mailbox_enable,
 		virtual_mailbox_open,
 		virtual_mailbox_close,
+		NULL,
 		virtual_mailbox_create,
 		virtual_mailbox_update,
 		index_storage_mailbox_delete,


More information about the dovecot-cvs mailing list