]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
LAYOUT=index: Fixed error handling in mailbox creation race condition.
authorTimo Sirainen <tss@iki.fi>
Wed, 21 Oct 2015 16:12:45 +0000 (19:12 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 21 Oct 2015 16:12:45 +0000 (19:12 +0300)
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.

src/lib-storage/list/mailbox-list-index-backend.c

index 2bf45ef28d65e7b0bcb834aeac59530a8caf135c..74d7ee503610708bc7bb7545759adafa6524b1aa 100644 (file)
@@ -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;