dovecot-2.2: lib-storage: LAYOUT=index no longer keeps list inde...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Oct 21 02:47:21 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/0de24ac413c4
changeset: 17976:0de24ac413c4
user: Timo Sirainen <tss at iki.fi>
date: Tue Oct 21 05:46:22 2014 +0300
description:
lib-storage: LAYOUT=index no longer keeps list index locked while creating mailbox.
Mailbox opening can be slow and complicated and could even try to lock the
list index again. So it's a bit more racy now, but all mailbox formats can
already handle races with mailbox creation.
diffstat:
src/lib-storage/list/mailbox-list-index-backend.c | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diffs (66 lines):
diff -r d9f49ebe5e78 -r 0de24ac413c4 src/lib-storage/list/mailbox-list-index-backend.c
--- a/src/lib-storage/list/mailbox-list-index-backend.c Tue Oct 21 05:44:09 2014 +0300
+++ b/src/lib-storage/list/mailbox-list-index-backend.c Tue Oct 21 05:46:22 2014 +0300
@@ -262,9 +262,8 @@
static int
index_list_mailbox_create_selectable(struct mailbox *box,
- const struct mailbox_update *update)
+ const guid_128_t mailbox_guid)
{
- struct index_list_mailbox *ibox = INDEX_LIST_STORAGE_CONTEXT(box);
struct index_mailbox_list *list =
(struct index_mailbox_list *)box->list;
struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(box->list);
@@ -272,7 +271,7 @@
struct mailbox_list_index_record rec;
struct mailbox_list_index_node *node;
const void *data;
- bool expunged, created, success;
+ bool expunged, created;
uint32_t seq;
if (mailbox_list_index_sync_begin(&list->list, &sync_ctx) < 0)
@@ -297,11 +296,10 @@
node->flags = 0;
mail_index_update_flags(sync_ctx->trans, seq, MODIFY_REPLACE, 0);
- memcpy(rec.guid, update->mailbox_guid, sizeof(rec.guid));
+ memcpy(rec.guid, mailbox_guid, sizeof(rec.guid));
mail_index_update_ext(sync_ctx->trans, seq, ilist->ext_id, &rec, NULL);
- success = ibox->module_ctx.super.create_box(box, update, FALSE) == 0;
- if (mailbox_list_index_sync_end(&sync_ctx, success) < 0) {
+ if (mailbox_list_index_sync_end(&sync_ctx, TRUE) < 0) {
/* make sure we forget any changes done internally */
mailbox_list_index_reset(ilist);
return -1;
@@ -313,6 +311,7 @@
index_list_mailbox_create(struct mailbox *box,
const struct mailbox_update *update, bool directory)
{
+ struct index_list_mailbox *ibox = INDEX_LIST_STORAGE_CONTEXT(box);
struct index_mailbox_list *list =
(struct index_mailbox_list *)box->list;
struct mailbox_update new_update;
@@ -339,11 +338,19 @@
new_update = *update;
if (guid_128_is_empty(new_update.mailbox_guid))
guid_128_generate(new_update.mailbox_guid);
- ret = index_list_mailbox_create_selectable(box, &new_update);
+ ret = index_list_mailbox_create_selectable(box, new_update.mailbox_guid);
if (ret < 0) {
mail_storage_copy_list_error(box->storage, box->list);
return -1;
}
+ if (ret > 0) {
+ /* mailbox entry was created. create the mailbox
+ itself now after the mailbox list index is already
+ unlocked (to avoid deadlocks in case the create_box()
+ goes back to updating mailbox list index). */
+ if (ibox->module_ctx.super.create_box(box, update, FALSE) < 0)
+ return -1;
+ }
} else {
ret = 0;
}
More information about the dovecot-cvs
mailing list