dovecot-2.2: layout=index: Allow mailbox create/delete/rename du...
dovecot at dovecot.org
dovecot at dovecot.org
Thu May 30 21:45:25 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/e90e9a7c4ff8
changeset: 16427:e90e9a7c4ff8
user: Timo Sirainen <tss at iki.fi>
date: Thu May 30 21:45:13 2013 +0300
description:
layout=index: Allow mailbox create/delete/rename during mailbox list iteration.
diffstat:
src/lib-storage/list/mailbox-list-index-iter.c | 9 +++----
src/lib-storage/list/mailbox-list-index.c | 28 ++++++++++++-------------
src/lib-storage/list/mailbox-list-index.h | 5 +---
3 files changed, 18 insertions(+), 24 deletions(-)
diffs (114 lines):
diff -r 528c64739e39 -r e90e9a7c4ff8 src/lib-storage/list/mailbox-list-index-iter.c
--- a/src/lib-storage/list/mailbox-list-index-iter.c Thu May 30 19:03:05 2013 +0300
+++ b/src/lib-storage/list/mailbox-list-index-iter.c Thu May 30 21:45:13 2013 +0300
@@ -59,7 +59,8 @@
ctx->info.ns = list->ns;
ctx->path = str_new(pool, 128);
ctx->next_node = ilist->mailbox_tree;
- ilist->iter_refcount++;
+ ctx->mailbox_pool = ilist->mailbox_pool;
+ pool_ref(ctx->mailbox_pool);
}
return &ctx->ctx;
}
@@ -188,10 +189,8 @@
if (ctx->backend_ctx != NULL)
ret = ilist->module_ctx.super.iter_deinit(ctx->backend_ctx);
- else {
- i_assert(ilist->iter_refcount > 0);
- ilist->iter_refcount--;
- }
+ else
+ pool_unref(&ctx->mailbox_pool);
pool_unref(&ctx->info_pool);
pool_unref(&_ctx->pool);
diff -r 528c64739e39 -r e90e9a7c4ff8 src/lib-storage/list/mailbox-list-index.c
--- a/src/lib-storage/list/mailbox-list-index.c Thu May 30 19:03:05 2013 +0300
+++ b/src/lib-storage/list/mailbox-list-index.c Thu May 30 21:45:13 2013 +0300
@@ -23,17 +23,25 @@
mail_index_reset_error(ilist->index);
}
+static void mailbox_list_index_init_pool(struct mailbox_list_index *ilist)
+{
+ ilist->mailbox_pool = pool_alloconly_create("mailbox list index", 4096);
+ hash_table_create_direct(&ilist->mailbox_names, ilist->mailbox_pool, 0);
+ hash_table_create_direct(&ilist->mailbox_hash, ilist->mailbox_pool, 0);
+}
+
void mailbox_list_index_reset(struct mailbox_list_index *ilist)
{
- i_assert(ilist->iter_refcount == 0);
+ hash_table_destroy(&ilist->mailbox_names);
+ hash_table_destroy(&ilist->mailbox_hash);
+ pool_unref(&ilist->mailbox_pool);
- hash_table_clear(ilist->mailbox_names, TRUE);
- hash_table_clear(ilist->mailbox_hash, TRUE);
- p_clear(ilist->mailbox_pool);
ilist->mailbox_tree = NULL;
ilist->highest_name_id = 0;
ilist->sync_log_file_seq = 0;
ilist->sync_log_file_offset = 0;
+
+ mailbox_list_index_init_pool(ilist);
}
static int mailbox_list_index_index_open(struct mailbox_list *list)
@@ -300,8 +308,6 @@
const struct mail_index_header *hdr;
const char *error;
- i_assert(ilist->iter_refcount == 0);
-
hdr = mail_index_get_header(view);
if (!force &&
hdr->log_file_seq == ilist->sync_log_file_seq &&
@@ -357,11 +363,6 @@
struct mail_index_view *view;
int ret;
- if (ilist->iter_refcount > 0) {
- /* someone's already iterating. don't break them. */
- return 0;
- }
-
if (mailbox_list_index_index_open(list) < 0)
return -1;
if (mail_index_refresh(ilist->index) < 0) {
@@ -608,10 +609,7 @@
ilist->subs_hdr_ext_id = mail_index_ext_register(ilist->index, "subs",
sizeof(uint32_t), 0,
sizeof(uint32_t));
-
- ilist->mailbox_pool = pool_alloconly_create("mailbox list index", 4096);
- hash_table_create_direct(&ilist->mailbox_names, ilist->mailbox_pool, 0);
- hash_table_create_direct(&ilist->mailbox_hash, ilist->mailbox_pool, 0);
+ mailbox_list_index_init_pool(ilist);
mailbox_list_index_status_init_finish(list);
}
diff -r 528c64739e39 -r e90e9a7c4ff8 src/lib-storage/list/mailbox-list-index.h
--- a/src/lib-storage/list/mailbox-list-index.h Thu May 30 19:03:05 2013 +0300
+++ b/src/lib-storage/list/mailbox-list-index.h Thu May 30 21:45:13 2013 +0300
@@ -87,10 +87,6 @@
struct mail_index *index;
uint32_t ext_id, msgs_ext_id, hmodseq_ext_id, subs_hdr_ext_id;
- /* Number of iterations going on. Don't refresh mailbox list while
- any iterations are going on. */
- int iter_refcount;
-
pool_t mailbox_pool;
/* uin32_t id => name */
HASH_TABLE(void *, char *) mailbox_names;
@@ -115,6 +111,7 @@
struct mailbox_list_index_iterate_context {
struct mailbox_list_iterate_context ctx;
struct mailbox_list_iterate_context *backend_ctx;
+ pool_t mailbox_pool;
struct mailbox_info info;
pool_t info_pool;
More information about the dovecot-cvs
mailing list