Mercurial > dovecot > core-2.2
changeset 21592:1a2afcda9eb1
lib-storage: mail_storage_init/deinit() is now reference counted.
This allows calling them multiple times and only the final deinit frees the
data.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Sun, 19 Feb 2017 02:02:20 +0200 |
parents | f2d5416e0d7d |
children | e8dfebca6899 |
files | src/lib-storage/mail-storage-service.c src/lib-storage/mail-storage.c |
diffstat | 2 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/mail-storage-service.c Sun Feb 19 02:01:24 2017 +0200 +++ b/src/lib-storage/mail-storage-service.c Sun Feb 19 02:02:20 2017 +0200 @@ -894,8 +894,6 @@ mail_storage_service_time_moved); mail_storage_init(); - mail_storage_register_all(); - mailbox_list_register_all(); pool = pool_alloconly_create("mail storage service", 2048); ctx = p_new(pool, struct mail_storage_service_ctx, 1);
--- a/src/lib-storage/mail-storage.c Sun Feb 19 02:01:24 2017 +0200 +++ b/src/lib-storage/mail-storage.c Sun Feb 19 02:02:20 2017 +0200 @@ -43,17 +43,26 @@ MODULE_CONTEXT_INIT(&mail_index_module_register); ARRAY_TYPE(mail_storage) mail_storage_classes; +static int mail_storage_init_refcount = 0; + void mail_storage_init(void) { + if (mail_storage_init_refcount++ > 0) + return; dsasl_clients_init(); mailbox_attributes_init(); mailbox_lists_init(); mail_storage_hooks_init(); i_array_init(&mail_storage_classes, 8); + mail_storage_register_all(); + mailbox_list_register_all(); } void mail_storage_deinit(void) { + i_assert(mail_storage_init_refcount > 0); + if (--mail_storage_init_refcount > 0) + return; if (mail_search_register_human != NULL) mail_search_register_deinit(&mail_search_register_human); if (mail_search_register_imap != NULL)