Mercurial > dovecot > core-2.2
changeset 22330:ac8ac56cab89
lib-storage: mailbox_create_missing_dir() - Handle mailbox delete race condition
Make sure the directory isn't created if the mail root directory no longer
exists. This might happen during mailbox deletion when another process is
opening the mailbox at the same time.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Wed, 12 Jul 2017 16:18:42 +0300 |
parents | f2e7b5010810 |
children | 0ec61a44ed7b |
files | src/lib-storage/mail-storage.c |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/mail-storage.c Wed Jul 12 16:15:13 2017 +0300 +++ b/src/lib-storage/mail-storage.c Wed Jul 12 16:18:42 2017 +0300 @@ -2725,6 +2725,15 @@ if (stat(dir, &st) == 0) return 0; + if (null_strcmp(dir, mail_dir) != 0 && + stat(mail_dir, &st) < 0 && (errno == ENOENT || errno == ENOTDIR)) { + /* Race condition - mail root directory doesn't exist + anymore either. We shouldn't create this directory + anymore. */ + mailbox_set_deleted(box); + return -1; + } + return mailbox_mkdir(box, dir, type); }