]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Mark index deleted if index log file is missing
authorAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 18 Jul 2017 11:37:53 +0000 (14:37 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 18 Jul 2017 12:40:29 +0000 (15:40 +0300)
This fixes all kinds of errors caused by mailbox being
deleted by another process.

src/lib-index/mail-index.c

index 537a998114fd63448c508e1df4b28ed1430d9198..b07a9b927f69b659b7f3a5ae18b4d482af316be5 100644 (file)
@@ -931,6 +931,20 @@ void mail_index_file_set_syscall_error(struct mail_index *index,
        i_assert(filepath != NULL);
        i_assert(function != NULL);
 
+       if (errno == ENOENT) {
+               struct stat st;
+               int old_errno = errno;
+               i_assert(index->log->filepath != NULL);
+               if (nfs_safe_stat(index->log->filepath, &st) < 0 &&
+                   errno == ENOENT) {
+                       /* the index log has gone away */
+                       index->index_deleted = TRUE;
+                       errno = old_errno;
+                       return;
+               }
+               errno = old_errno;
+       }
+
        if (ENOSPACE(errno)) {
                index->nodiskspace = TRUE;
                if ((index->flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) == 0)