Mercurial > dovecot > original-hg > dovecot-1.2
changeset 2911:f2c2b17d7659 HEAD
Changed mail_index_map_to_memory() to mail_index_map_clone(). Even if the
index is already in memory, we wish to copy it instead of just raising
refcount. Fixes some problems with mmap_disable=yes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 29 Nov 2004 02:48:45 +0200 |
parents | 1a9e4676196d |
children | e491b5d1a73a |
files | src/lib-index/mail-index-private.h src/lib-index/mail-index-sync-update.c src/lib-index/mail-index-view-sync.c src/lib-index/mail-index.c |
diffstat | 4 files changed, 16 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-private.h Mon Nov 29 02:27:47 2004 +0200 +++ b/src/lib-index/mail-index-private.h Mon Nov 29 02:48:45 2004 +0200 @@ -175,7 +175,7 @@ /* Unreference given mapping and unmap it if it's dropped to zero. */ void mail_index_unmap(struct mail_index *index, struct mail_index_map *map); struct mail_index_map * -mail_index_map_to_memory(struct mail_index_map *map, uint32_t new_record_size); +mail_index_map_clone(struct mail_index_map *map, uint32_t new_record_size); uint32_t mail_index_map_lookup_ext(struct mail_index_map *map, const char *name);
--- a/src/lib-index/mail-index-sync-update.c Mon Nov 29 02:27:47 2004 +0200 +++ b/src/lib-index/mail-index-sync-update.c Mon Nov 29 02:48:45 2004 +0200 @@ -16,6 +16,10 @@ struct mail_index_map *map) { struct mail_index_view *view = ctx->view; + + /* if map still exists after this, it's only in views. */ + view->map->write_to_disk = FALSE; + mail_index_unmap(view->index, view->map); view->map = map; view->map->refcount++; @@ -198,13 +202,13 @@ return -1; } - if (!view->map->write_to_disk) { + if (!view->map->write_to_disk || view->map->refcount != 1) { /* expunges have to be atomic. so we'll have to copy the mapping, do the changes there and then finally replace the whole index file. to avoid extra disk I/O we copy the index into memory rather than to temporary file */ - map = mail_index_map_to_memory(map, map->hdr.record_size); + map = mail_index_map_clone(map, map->hdr.record_size); mail_index_sync_replace_map(ctx, map); } i_assert(MAIL_INDEX_MAP_IS_IN_MEMORY(map)); @@ -480,7 +484,7 @@ /* create a new mapping without records. a bit kludgy. */ old_records_count = map->records_count; map->records_count = 0; - new_map = mail_index_map_to_memory(map, offset); + new_map = mail_index_map_clone(map, offset); map->records_count = old_records_count; if (old_size > ext[ext_id].record_size) {
--- a/src/lib-index/mail-index-view-sync.c Mon Nov 29 02:27:47 2004 +0200 +++ b/src/lib-index/mail-index-view-sync.c Mon Nov 29 02:48:45 2004 +0200 @@ -139,12 +139,14 @@ uint32_t old_records_count = view->map->records_count; if (view->map != view->index->map) { + i_assert(view->map->records_count >= + view->hdr.messages_count); + view->map->records_count = view->hdr.messages_count; ctx->sync_map_update = TRUE; - view->map->records_count = view->hdr.messages_count; } - map = mail_index_map_to_memory(view->map, - view->map->hdr.record_size); + map = mail_index_map_clone(view->map, + view->map->hdr.record_size); view->map->records_count = old_records_count; mail_index_unmap(view->index, view->map); view->map = map;
--- a/src/lib-index/mail-index.c Mon Nov 29 02:27:47 2004 +0200 +++ b/src/lib-index/mail-index.c Mon Nov 29 02:48:45 2004 +0200 @@ -723,8 +723,8 @@ } else { /* create a copy of the mapping instead so we don't have to re-read it */ - map = mail_index_map_to_memory(index->map, - index->map->hdr.record_size); + map = mail_index_map_clone(index->map, + index->map->hdr.record_size); } index->map->refcount--; index->map = NULL; @@ -772,7 +772,7 @@ } struct mail_index_map * -mail_index_map_to_memory(struct mail_index_map *map, uint32_t new_record_size) +mail_index_map_clone(struct mail_index_map *map, uint32_t new_record_size) { struct mail_index_map *mem_map; struct mail_index_header *hdr; @@ -781,12 +781,6 @@ size_t size, copy_size; unsigned int i, count; - if (MAIL_INDEX_MAP_IS_IN_MEMORY(map) && - map->hdr.record_size == new_record_size) { - map->refcount++; - return map; - } - size = map->records_count * new_record_size; mem_map = i_new(struct mail_index_map, 1);