From: Timo Sirainen Date: Wed, 21 Oct 2015 16:12:45 +0000 (+0300) Subject: LAYOUT=index: Fixed error handling in mailbox creation race condition. X-Git-Tag: 2.2.20.rc1~124 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=453278403dbd2083b0c9a7aa5edb68d3f82ad4f6;p=thirdparty%2Fdovecot%2Fcore.git LAYOUT=index: Fixed error handling in mailbox creation race condition. If two processes create the same mailbox, the other one ends up being deleted on failure. However, if the deletion itself also failed the state becomes a big ambiguous. We don't want to return MAIL_ERROR_EXISTS in that case, because the caller may try to open the mailbox with the inconsistent state and fail. So we'll instead return the original mailbox_delete() error to the caller. --- diff --git a/src/lib-storage/list/mailbox-list-index-backend.c b/src/lib-storage/list/mailbox-list-index-backend.c index 2bf45ef28d..74d7ee5036 100644 --- a/src/lib-storage/list/mailbox-list-index-backend.c +++ b/src/lib-storage/list/mailbox-list-index-backend.c @@ -374,7 +374,8 @@ index_list_mailbox_create(struct mailbox *box, if (ret <= 0) { /* failed to add to list. rollback the backend mailbox creation */ - (void)mailbox_delete(box); + if (mailbox_delete(box) < 0) + ret = -1; } } list->create_mailbox_name = old_name;