Mercurial > dovecot > core-2.2
changeset 270:6dfdda80e822 HEAD
crashed if index or hash was rebuilt
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 19 Sep 2002 20:04:00 +0300 |
parents | a4eb58705351 |
children | bd51b6445bcd |
files | src/lib-index/mail-hash.c src/lib-index/mail-index-open.c |
diffstat | 2 files changed, 5 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-hash.c Tue Sep 17 08:19:22 2002 +0300 +++ b/src/lib-index/mail-hash.c Thu Sep 19 20:04:00 2002 +0300 @@ -52,7 +52,6 @@ MailHashHeader *header; unsigned int anon_mmap:1; - unsigned int dirty_mmap:1; unsigned int modified:1; }; @@ -94,9 +93,10 @@ hash_set_syscall_error(hash, "munmap()"); } + hash->header = NULL; + hash->mmap_base = mmap_rw_file(hash->fd, &hash->mmap_length); if (hash->mmap_base == MAP_FAILED) { - hash->mmap_base = NULL; hash->header = NULL; hash_set_syscall_error(hash, "mmap()"); return FALSE; @@ -112,26 +112,23 @@ sizeof(MailHashRecord) != 0) { /* hash must be corrupted, rebuilding should have noticed if it was only partially written. */ - hash->header = NULL; index_set_error(hash->index, "Corrupted hash file %s: " "Invalid file size %"PRIuSIZE_T"", hash->filepath, hash->mmap_length); return FALSE; } - hash->header = hash->mmap_base; hash->size = (hash->mmap_length - sizeof(MailHashHeader)) / sizeof(MailHashRecord); if (hash->size < MIN_HASH_SIZE || hash->size > MAX_HASH_SIZE) { /* invalid size, probably corrupted. */ - hash->header = NULL; index_set_error(hash->index, "Corrupted hash file %s: " "Invalid size %u", hash->filepath, hash->size); return FALSE; } - hash->dirty_mmap = FALSE; + hash->header = hash->mmap_base; return TRUE; } @@ -462,7 +459,7 @@ hash->anon_mmap = fd == -1; if (fd != -1) { - if (!mmap_update_real(hash)) + if (!mmap_update_real(hash) || !hash_verify_header(hash)) return FALSE; }
--- a/src/lib-index/mail-index-open.c Tue Sep 17 08:19:22 2002 +0300 +++ b/src/lib-index/mail-index-open.c Thu Sep 19 20:04:00 2002 +0300 @@ -185,6 +185,7 @@ /* index is corrupted, rebuild */ if (!index->rebuild(index)) return FALSE; + hdr = index->header; /* no inconsistency problems while still opening the index */