Mercurial > dovecot > original-hg > dovecot-1.2
changeset 3179:c620532e7bc8 HEAD
Assert if mail_index_map() is called recursively.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 05 Mar 2005 21:19:24 +0200 |
parents | 845c49350468 |
children | ef16bb8091aa |
files | src/lib-index/mail-index-private.h src/lib-index/mail-index.c |
diffstat | 2 files changed, 20 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-private.h Sat Mar 05 21:15:52 2005 +0200 +++ b/src/lib-index/mail-index-private.h Sat Mar 05 21:19:24 2005 +0200 @@ -155,6 +155,7 @@ unsigned int readonly:1; unsigned int fsck:1; unsigned int sync_update:1; + unsigned int mapping:1; }; enum mail_index_sync_handler_type {
--- a/src/lib-index/mail-index.c Sat Mar 05 21:15:52 2005 +0200 +++ b/src/lib-index/mail-index.c Sat Mar 05 21:19:24 2005 +0200 @@ -845,17 +845,23 @@ struct mail_index_map *map; int ret; + i_assert(!index->mapping); i_assert(index->map == NULL || index->map->refcount > 0); i_assert(index->lock_type != F_UNLCK); + index->mapping = TRUE; + if (!force && index->map != NULL) { i_assert(index->hdr != NULL); ret = mail_index_map_try_existing(index->map); - if (ret != 0) + if (ret != 0) { + index->mapping = FALSE; return ret; + } if (index->lock_type == F_WRLCK) { /* we're syncing, don't break the mapping */ + index->mapping = FALSE; return 1; } } @@ -900,22 +906,26 @@ ret = mail_index_read_map_with_retry(index, &map, force); i_assert(index->map == NULL); - if (ret <= 0) { - mail_index_unmap_forced(index, map); - return ret; + if (ret > 0) { + ret = mail_index_check_header(index, map); + if (ret < 0) + ret = 0; + else if (ret == 0) { + index->fsck = TRUE; + ret = 1; + } } - ret = mail_index_check_header(index, map); - if (ret < 0) { + if (ret <= 0) { mail_index_unmap_forced(index, map); - return 0; + index->mapping = FALSE; + return ret; } - if (ret == 0) - index->fsck = TRUE; index->hdr = &map->hdr; index->map = map; i_assert(map->hdr.messages_count == map->records_count); + index->mapping = FALSE; return 1; }