Mercurial > dovecot > original-hg > dovecot-1.2
changeset 392:2f3d3ba129e1 HEAD
Fixes for first_hole_* updating. Removed last_lookup, it doesn't speed up
much anymore and it's just annoyance to keep valid.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 09 Oct 2002 16:56:44 +0300 |
parents | 55f04b297f87 |
children | f09e67287f7d |
files | src/lib-index/mail-index-fsck.c src/lib-index/mail-index.c src/lib-index/mail-index.h |
diffstat | 3 files changed, 23 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-fsck.c Wed Oct 09 02:39:19 2002 +0300 +++ b/src/lib-index/mail-index-fsck.c Wed Oct 09 16:56:44 2002 +0300 @@ -81,7 +81,7 @@ if (rec->uid == 0) { /* expunged message */ pos = INDEX_RECORD_INDEX(index, rec); - if (hdr->first_hole_index == 0) { + if (hdr->first_hole_records == 0) { hdr->first_hole_index = pos; hdr->first_hole_records = 1; } else if (hdr->first_hole_index +
--- a/src/lib-index/mail-index.c Wed Oct 09 02:39:19 2002 +0300 +++ b/src/lib-index/mail-index.c Wed Oct 09 16:56:44 2002 +0300 @@ -40,9 +40,6 @@ (void)ftruncate(index->fd, (off_t)index->mmap_full_length); } - index->last_lookup_seq = 0; - index->last_lookup = NULL; - /* keep the header set even if we fail, so we can update the flags */ hdr = index->mmap_base; index->header = hdr; @@ -294,10 +291,6 @@ old_lock_type = index->lock_type; index->lock_type = MAIL_LOCK_UNLOCK; - /* reset last_lookup so rebuilds don't try to use it */ - index->last_lookup_seq = 0; - index->last_lookup = NULL; - if (old_lock_type == MAIL_LOCK_SHARED) { /* releasing shared lock. we may need to update some flags in header. */ @@ -413,8 +406,7 @@ } /* check that first_hole_records is in valid range */ - if (hdr->first_hole_records > max_records || - hdr->first_hole_index + hdr->first_hole_records > max_records) { + if (max_records - hdr->first_hole_index < hdr->first_hole_records) { index_set_corrupted(index, "first_hole_records points outside file"); return FALSE; @@ -440,12 +432,6 @@ i_assert(seq > 0); i_assert(index->lock_type != MAIL_LOCK_UNLOCK); - if (seq == index->last_lookup_seq && - index->last_lookup != NULL && index->last_lookup->uid != 0) { - /* wanted the same record as last time */ - return index->last_lookup; - } - hdr = index->header; if (seq > hdr->messages_count) { /* out of range */ @@ -489,8 +475,6 @@ return NULL; } - index->last_lookup = rec; - index->last_lookup_seq = seq; return rec; } @@ -710,50 +694,25 @@ i_assert(seq != 0); i_assert(rec->uid != 0); - if (seq != 0 && index->modifylog != NULL) { - if (!mail_modifylog_add_expunge(index->modifylog, seq, - rec->uid, external_change)) - return FALSE; - } - - /* expunge() may be called while index is being rebuilt and when - there's no hash yet */ - if (index->tree != NULL) - mail_tree_delete(index->tree, rec->uid); - else { - /* make sure it also gets updated */ - index->header->flags |= MAIL_INDEX_FLAG_REBUILD_TREE; - } - - /* setting UID to 0 is enough for deleting the mail from index */ - rec->uid = 0; - - /* update last_lookup_seq */ - if (seq != 0) { - /* note that last_lookup can be left to point to - invalid record so that next() works properly */ - if (seq == index->last_lookup_seq) - index->last_lookup = NULL; - else if (seq < index->last_lookup_seq) - index->last_lookup_seq--; - } - if (!mail_index_verify_hole_range(index)) return FALSE; hdr = index->header; + /* setting UID to 0 is enough for deleting the mail from index */ + rec->uid = 0; + /* update first hole */ idx = INDEX_RECORD_INDEX(index, rec); if (hdr->first_hole_records == 0) { /* first deleted message in index */ hdr->first_hole_index = idx; hdr->first_hole_records = 1; - } else if (idx == hdr->first_hole_index+1) { + } else if (idx+1 == hdr->first_hole_index) { /* deleted the previous record before hole */ hdr->first_hole_index--; hdr->first_hole_records++; - } else if (hdr->first_hole_index + hdr->first_hole_records == idx) { + } else if (idx == hdr->first_hole_index + hdr->first_hole_records) { /* deleted the next record after hole */ hdr->first_hole_records++; update_first_hole_records(index); @@ -788,6 +747,21 @@ hdr->flags |= MAIL_INDEX_FLAG_COMPRESS; } + /* expunge() may be called while index is being rebuilt and when + tree file hasn't been opened yet */ + if (index->tree != NULL) + mail_tree_delete(index->tree, rec->uid); + else { + /* make sure it also gets updated */ + index->header->flags |= MAIL_INDEX_FLAG_REBUILD_TREE; + } + + if (seq != 0 && index->modifylog != NULL) { + if (!mail_modifylog_add_expunge(index->modifylog, seq, + rec->uid, external_change)) + return FALSE; + } + return TRUE; }
--- a/src/lib-index/mail-index.h Wed Oct 09 02:39:19 2002 +0300 +++ b/src/lib-index/mail-index.h Wed Oct 09 16:56:44 2002 +0300 @@ -333,8 +333,6 @@ MailLockType lock_type; MailIndexHeader *header; - MailIndexRecord *last_lookup; - unsigned int last_lookup_seq; unsigned int first_recent_uid; unsigned int modifylog_id; @@ -356,8 +354,7 @@ #define MAIL_INDEX_PRIVATE_FILL \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ - 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0 \ /* defaults - same as above but prefixed with mail_index_. */ int mail_index_open(MailIndex *index, int update_recent, int fast);