From: Timo Sirainen Date: Mon, 11 Aug 2003 14:28:27 +0000 (+0300) Subject: some opening fixes X-Git-Tag: 1.1.alpha1~4425 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5024402a628e9a6fc21eb8cdf2778486c6f2f92c;p=thirdparty%2Fdovecot%2Fcore.git some opening fixes --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-cache.c b/src/lib-index/mail-cache.c index ee8fd56b1e..f3e269789d 100644 --- a/src/lib-index/mail-cache.c +++ b/src/lib-index/mail-cache.c @@ -199,7 +199,10 @@ static int mail_cache_file_reopen(struct mail_cache *cache) { int fd; - i_assert(!cache->anon_mmap); + if (cache->anon_mmap) { + /* cache was set corrupted, we'll have to quit */ + return FALSE; + } fd = open(cache->filepath, O_RDWR); if (fd == -1) diff --git a/src/lib-index/mail-index-open.c b/src/lib-index/mail-index-open.c index 974a85fa47..55cee26d2a 100644 --- a/src/lib-index/mail-index-open.c +++ b/src/lib-index/mail-index-open.c @@ -297,9 +297,11 @@ static int mail_index_open_index(struct mail_index *index, if ((ret = mail_index_read_header(index, &hdr)) < 0) return FALSE; + index->indexid = hdr.indexid; if (ret == 0 || hdr.major_version != MAIL_INDEX_MAJOR_VERSION || - (hdr.flags & MAIL_INDEX_HDR_FLAG_REBUILD) != 0) { + (hdr.flags & MAIL_INDEX_HDR_FLAG_REBUILD) != 0 || + !mail_index_mmap_update(index)) { if ((flags & MAIL_INDEX_OPEN_FLAG_CREATE) == 0) return FALSE; @@ -318,11 +320,6 @@ static int mail_index_open_index(struct mail_index *index, return FALSE; } - index->indexid = hdr.indexid; - - if (!mail_index_mmap_update(index)) - return FALSE; - if (index->lock_type == MAIL_LOCK_SHARED) { /* we don't want to keep the shared lock while opening indexes. opening should work unlocked and some