dovecot: Removed index->hdr. Use index->map->hdr instead.
dovecot at dovecot.org
dovecot at dovecot.org
Tue Jun 19 15:07:45 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/002aa9bbfcb2
changeset: 5772:002aa9bbfcb2
user: Timo Sirainen <tss at iki.fi>
date: Tue Jun 19 15:05:16 2007 +0300
description:
Removed index->hdr. Use index->map->hdr instead.
diffstat:
10 files changed, 25 insertions(+), 35 deletions(-)
src/lib-index/mail-hash.c | 10 +++++-----
src/lib-index/mail-index-map.c | 2 --
src/lib-index/mail-index-private.h | 1 -
src/lib-index/mail-index-sync-update.c | 8 ++------
src/lib-index/mail-index-sync.c | 2 +-
src/lib-index/mail-index-view-sync.c | 2 +-
src/lib-index/mail-index-view.c | 4 ++--
src/lib-index/mail-index.c | 14 +++++---------
src/lib-index/mail-transaction-log-file.c | 8 ++++----
src/lib-index/mailbox-list-index.c | 9 +++++----
diffs (238 lines):
diff -r 433ae8a32506 -r 002aa9bbfcb2 src/lib-index/mail-hash.c
--- 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 @@ static int mail_hash_check_header(struct
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 @@ mail_hash_header_init(struct mail_hash *
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 @@ int mail_hash_lock(struct mail_hash *has
}
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 @@ static int mail_hash_grow_file(struct ma
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. */
diff -r 433ae8a32506 -r 002aa9bbfcb2 src/lib-index/mail-index-map.c
--- 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 @@ int mail_index_map(struct mail_index *in
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 @@ int mail_index_map(struct mail_index *in
if (ret > 0) {
i_assert(map->hdr.messages_count == map->records_count);
- index->hdr = &map->hdr;
index->map = map;
} else {
if (map != NULL)
diff -r 433ae8a32506 -r 002aa9bbfcb2 src/lib-index/mail-index-private.h
--- 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 @@ struct mail_index {
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
diff -r 433ae8a32506 -r 002aa9bbfcb2 src/lib-index/mail-index-sync-update.c
--- 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 @@ static void mail_index_sync_replace_map(
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 @@ int mail_index_sync_map(struct mail_inde
}
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 @@ int mail_index_sync_map(struct mail_inde
if (type != MAIL_INDEX_SYNC_HANDLER_VIEW) {
i_assert(index->map == map);
index->map = NULL;
- index->hdr = NULL;
}
*_map = map;
diff -r 433ae8a32506 -r 002aa9bbfcb2 src/lib-index/mail-index-sync.c
--- 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 @@ int mail_index_sync_begin(struct mail_in
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)) {
diff -r 433ae8a32506 -r 002aa9bbfcb2 src/lib-index/mail-index-view-sync.c
--- 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 @@ mail_transaction_log_sort_expunges(ARRAY
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 */
diff -r 433ae8a32506 -r 002aa9bbfcb2 src/lib-index/mail-index-view.c
--- 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 @@ static int _view_lookup_full(struct mail
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;
diff -r 433ae8a32506 -r 002aa9bbfcb2 src/lib-index/mail-index.c
--- 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 @@ static bool mail_index_open_files(struct
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 mail_index_open(struct mail_index *i
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 @@ int mail_index_move_to_memory(struct mai
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 @@ int mail_index_move_to_memory(struct mai
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()");
}
diff -r 433ae8a32506 -r 002aa9bbfcb2 src/lib-index/mail-transaction-log-file.c
--- 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 @@ mail_transaction_log_init_hdr(struct mai
&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;
}
diff -r 433ae8a32506 -r 002aa9bbfcb2 src/lib-index/mailbox-list-index.c
--- 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 @@ mailbox_list_index_check_header(struct m
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;
More information about the dovecot-cvs
mailing list