Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5772:002aa9bbfcb2 HEAD
Removed index->hdr. Use index->map->hdr instead.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 19 Jun 2007 15:05:16 +0300 |
parents | 433ae8a32506 |
children | 622ab4de7d66 |
files | src/lib-index/mail-hash.c src/lib-index/mail-index-map.c src/lib-index/mail-index-private.h src/lib-index/mail-index-sync-update.c src/lib-index/mail-index-sync.c src/lib-index/mail-index-view-sync.c src/lib-index/mail-index-view.c src/lib-index/mail-index.c src/lib-index/mail-transaction-log-file.c src/lib-index/mailbox-list-index.c |
diffstat | 10 files changed, 25 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-hash.c Tue Jun 19 14:56:33 2007 +0300 +++ b/src/lib-index/mail-hash.c Tue Jun 19 15:05:16 2007 +0300 @@ -153,7 +153,7 @@ if (hdr->version != MAIL_HASH_VERSION || (hdr->last_uid != 0 && - hdr->uid_validity != hash->index->hdr->uid_validity) || + hdr->uid_validity != hash->index->map->hdr.uid_validity) || (hdr->corrupted && hash->change_offset_end == 0)) { /* silent rebuild */ return -1; @@ -473,10 +473,10 @@ hdr->record_size = hash->record_size; /* note that since the index may not have been synced yet, the uid_validity may be 0 */ - hdr->uid_validity = hash->index->hdr->uid_validity; + hdr->uid_validity = hash->index->map->hdr.uid_validity; if (initial_count == 0) - initial_count = I_MAX(hash->index->hdr->messages_count, 25); + initial_count = I_MAX(hash->index->map->hdr.messages_count, 25); hdr->hash_size = I_MAX(primes_closest(initial_count * 2), MAIL_HASH_MIN_SIZE); @@ -678,7 +678,7 @@ } if (hash->hdr->uid_validity == 0) { i_assert(hash->hdr->last_uid == 0); - hash->hdr->uid_validity = hash->index->hdr->uid_validity; + hash->hdr->uid_validity = hash->index->map->hdr.uid_validity; } hash->locked = TRUE; return 1; @@ -768,7 +768,7 @@ size_t new_size, grow_size; grow_size = hash->mmap_size * 100 / MAIL_HASH_GROW_PERCENTAGE; - message_count = hash->index->hdr->messages_count; + message_count = hash->index->map->hdr.messages_count; if (hash->hdr->record_count < message_count) { /* if lots of messages have been added, the grow percentage may not be enough. */
--- a/src/lib-index/mail-index-map.c Tue Jun 19 14:56:33 2007 +0300 +++ b/src/lib-index/mail-index-map.c Tue Jun 19 15:05:16 2007 +0300 @@ -769,7 +769,6 @@ if (map == NULL) map = mail_index_map_alloc(index); - index->hdr = NULL; index->map = NULL; ret = mail_index_map_update(index, &map, type, lock_id_r); @@ -777,7 +776,6 @@ if (ret > 0) { i_assert(map->hdr.messages_count == map->records_count); - index->hdr = &map->hdr; index->map = map; } else { if (map != NULL)
--- a/src/lib-index/mail-index-private.h Tue Jun 19 14:56:33 2007 +0300 +++ b/src/lib-index/mail-index-private.h Tue Jun 19 15:05:16 2007 +0300 @@ -156,7 +156,6 @@ char *filepath; int fd; - const struct mail_index_header *hdr; struct mail_index_map *map; uint32_t indexid; /* last known log_file_tail_offset in main index file. used for
--- a/src/lib-index/mail-index-sync-update.c Tue Jun 19 14:56:33 2007 +0300 +++ b/src/lib-index/mail-index-sync-update.c Tue Jun 19 15:05:16 2007 +0300 @@ -80,10 +80,8 @@ mail_index_unmap(view->index, &view->map); view->map = map; - if (ctx->type != MAIL_INDEX_SYNC_HANDLER_VIEW) { + if (ctx->type != MAIL_INDEX_SYNC_HANDLER_VIEW) view->index->map = map; - view->index->hdr = &map->hdr; - } } void mail_index_sync_move_to_private(struct mail_index_sync_map_ctx *ctx) @@ -743,9 +741,8 @@ } if (type != MAIL_INDEX_SYNC_HANDLER_VIEW) { - i_assert(index->map == NULL && index->hdr == NULL); + i_assert(index->map == NULL); index->map = map; - index->hdr = &map->hdr; } mail_index_sync_map_init(&sync_map_ctx, view, type); @@ -813,7 +810,6 @@ if (type != MAIL_INDEX_SYNC_HANDLER_VIEW) { i_assert(index->map == map); index->map = NULL; - index->hdr = NULL; } *_map = map;
--- a/src/lib-index/mail-index-sync.c Tue Jun 19 14:56:33 2007 +0300 +++ b/src/lib-index/mail-index-sync.c Tue Jun 19 15:05:16 2007 +0300 @@ -363,7 +363,7 @@ mail_transaction_log_sync_unlock(index->log); return -1; } - hdr = index->hdr; + hdr = &index->map->hdr; if (!mail_index_need_sync(index, hdr, sync_recent, log_file_seq, log_file_offset)) {
--- a/src/lib-index/mail-index-view-sync.c Tue Jun 19 14:56:33 2007 +0300 +++ b/src/lib-index/mail-index-view-sync.c Tue Jun 19 15:05:16 2007 +0300 @@ -89,7 +89,7 @@ static int view_sync_set_log_view_range(struct mail_index_view *view) { - const struct mail_index_header *hdr = view->index->hdr; + const struct mail_index_header *hdr = &view->index->map->hdr; int ret; /* the view begins from the first non-synced transaction */
--- a/src/lib-index/mail-index-view.c Tue Jun 19 14:56:33 2007 +0300 +++ b/src/lib-index/mail-index-view.c Tue Jun 19 15:05:16 2007 +0300 @@ -228,8 +228,8 @@ usually there are only a few expunges, so just going downwards from our initial sequence position is probably faster than binary search. */ - if (seq > view->index->hdr->messages_count) - seq = view->index->hdr->messages_count; + if (seq > view->index->map->hdr.messages_count) + seq = view->index->map->hdr.messages_count; if (seq == 0) { /* everything is expunged from head. use the old record. */ *map_r = view->map;
--- a/src/lib-index/mail-index.c Tue Jun 19 14:56:33 2007 +0300 +++ b/src/lib-index/mail-index.c Tue Jun 19 15:05:16 2007 +0300 @@ -433,7 +433,6 @@ if (ret == 0) { /* doesn't exist / corrupted */ index->map = mail_index_map_alloc(index); - index->hdr = &index->map->hdr; } } if (ret < 0) { @@ -456,8 +455,9 @@ int i = 0, ret = 1; if (index->opened) { - if (index->hdr != NULL && - (index->hdr->flags & MAIL_INDEX_HDR_FLAG_CORRUPTED) != 0) { + if (index->map != NULL && + (index->map->hdr.flags & + MAIL_INDEX_HDR_FLAG_CORRUPTED) != 0) { /* corrupted, reopen files */ mail_index_close(index); } else { @@ -661,7 +661,6 @@ map = mail_index_map_clone(index->map); mail_index_unmap(index, &index->map); index->map = map; - index->hdr = &map->hdr; } if (index->log != NULL) { @@ -681,16 +680,13 @@ void mail_index_mark_corrupted(struct mail_index *index) { - struct mail_index_header hdr; - mail_index_set_inconsistent(index); if (index->readonly || index->map == NULL) return; - hdr = *index->hdr; - hdr.flags |= MAIL_INDEX_HDR_FLAG_CORRUPTED; - if (mail_index_write_base_header(index, &hdr) == 0) { + index->map->hdr.flags |= MAIL_INDEX_HDR_FLAG_CORRUPTED; + if (mail_index_write_base_header(index, &index->map->hdr) == 0) { if (!MAIL_INDEX_IS_IN_MEMORY(index) && fsync(index->fd) < 0) mail_index_set_syscall_error(index, "fsync()"); }
--- a/src/lib-index/mail-transaction-log-file.c Tue Jun 19 14:56:33 2007 +0300 +++ b/src/lib-index/mail-transaction-log-file.c Tue Jun 19 15:05:16 2007 +0300 @@ -158,10 +158,10 @@ &lock_id) <= 0) return -1; } - if (index->hdr != NULL) { - hdr->prev_file_seq = index->hdr->log_file_seq; - hdr->prev_file_offset = index->hdr->log_file_head_offset; - hdr->file_seq = index->hdr->log_file_seq + 1; + if (index->map != NULL) { + hdr->prev_file_seq = index->map->hdr.log_file_seq; + hdr->prev_file_offset = index->map->hdr.log_file_head_offset; + hdr->file_seq = index->map->hdr.log_file_seq + 1; } else { hdr->file_seq = 1; }
--- a/src/lib-index/mailbox-list-index.c Tue Jun 19 14:56:33 2007 +0300 +++ b/src/lib-index/mailbox-list-index.c Tue Jun 19 15:05:16 2007 +0300 @@ -122,16 +122,17 @@ if (hdr->next_uid == 0) return mailbox_list_index_set_corrupted(index, "next_uid is 0"); - if (index->mail_index->hdr == NULL) { + if (index->mail_index->map == NULL) { /* index already marked as corrupted */ return -1; } - if (hdr->uid_validity != index->mail_index->hdr->uid_validity && - index->mail_index->hdr->uid_validity != 0) { + if (hdr->uid_validity != index->mail_index->map->hdr.uid_validity && + index->mail_index->map->hdr.uid_validity != 0) { mail_index_set_error(index->mail_index, "uid_validity changed in file %s: %u -> %u", - index->filepath, index->mail_index->hdr->uid_validity, + index->filepath, + index->mail_index->map->hdr.uid_validity, hdr->uid_validity); mail_index_mark_corrupted(index->mail_index); return -1;