Mercurial > dovecot > original-hg > dovecot-1.2
diff src/lib-index/mail-transaction-log.c @ 4396:208194b3742a HEAD
Handle transaction log deletions silently. Handle whole index directory
deletions silently (the most common cases anyway).
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 17 Jun 2006 16:42:37 +0300 |
parents | abdef9d86a94 |
children | 1dc7ffa3c669 |
line wrap: on
line diff
--- a/src/lib-index/mail-transaction-log.c Sat Jun 17 16:03:27 2006 +0300 +++ b/src/lib-index/mail-transaction-log.c Sat Jun 17 16:42:37 2006 +0300 @@ -561,11 +561,25 @@ dev_t dev, ino_t ino, uoff_t file_size) { struct dotlock *dotlock; - mode_t old_mask; + struct stat st; + mode_t old_mask; int fd; i_assert(!MAIL_INDEX_IS_IN_MEMORY(log->index)); + if (stat(log->index->dir, &st) < 0) { + if (ENOTFOUND(errno)) { + /* the whole index directory was deleted, which means + the mailbox was deleted by another process. + fail silently. */ + mail_index_mark_corrupted(log->index); + return -1; + } + mail_index_file_set_syscall_error(log->index, log->index->dir, + "stat()"); + return -1; + } + /* With dotlocking we might already have path.lock created, so this filename has to be different. */ old_mask = umask(log->index->mode ^ 0666); @@ -921,15 +935,19 @@ path = t_strconcat(log->index->filepath, MAIL_TRANSACTION_LOG_SUFFIX, NULL); if (nfs_safe_stat(path, &st) < 0) { - mail_index_file_set_syscall_error(log->index, path, "stat()"); - return -1; - } - - if (log->head != NULL && - log->head->st_ino == st.st_ino && - CMP_DEV_T(log->head->st_dev, st.st_dev)) { - /* same file */ - return 0; + if (errno != ENOENT) { + mail_index_file_set_syscall_error(log->index, path, + "stat()"); + return -1; + } + /* log was deleted. just reopen/recreate it. */ + } else { + if (log->head != NULL && + log->head->st_ino == st.st_ino && + CMP_DEV_T(log->head->st_dev, st.st_dev)) { + /* same file */ + return 0; + } } file = create_if_needed ?