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.
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;