Mercurial > dovecot > original-hg > dovecot-1.2
changeset 4716:79edf40cc2f9 HEAD
Last keyword pool clearing optimization broke the keywords if we had to move
mails around in the file.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 26 Oct 2006 03:17:23 +0300 |
parents | fd469f910aa7 |
children | 392c7d4605be |
files | src/lib-storage/index/mbox/mbox-sync-private.h src/lib-storage/index/mbox/mbox-sync.c |
diffstat | 2 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-sync-private.h Wed Oct 25 23:25:03 2006 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync-private.h Thu Oct 26 03:17:23 2006 +0300 @@ -117,7 +117,10 @@ ARRAY_TYPE(sync_recs) syncs; struct mail_index_sync_rec sync_rec; + /* per-mail pool */ pool_t mail_keyword_pool; + /* used for mails[].keywords */ + pool_t saved_keywords_pool; uint32_t prev_msg_uid, next_uid, idx_next_uid; uint32_t seq, idx_seq, need_space_seq;
--- a/src/lib-storage/index/mbox/mbox-sync.c Wed Oct 25 23:25:03 2006 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync.c Thu Oct 26 03:17:23 2006 +0300 @@ -786,9 +786,17 @@ struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx; uoff_t end_offset, move_diff, extra_space, needed_space; uint32_t last_seq; + array_t ARRAY_DEFINE(keywords_copy, unsigned int); i_assert(mail_ctx->mail.uid == 0 || mail_ctx->mail.space > 0 || mail_ctx->mail.offset == mail_ctx->hdr_offset); + + /* mail's keywords are allocated from a pool that's cleared for each + mail. we'll need to copy it to something more permanent. */ + ARRAY_CREATE(&keywords_copy, sync_ctx->saved_keywords_pool, + unsigned int, array_count(&mail_ctx->mail.keywords)); + array_append_array(&keywords_copy, &mail_ctx->mail.keywords); + mail_ctx->mail.keywords = keywords_copy; array_append(&sync_ctx->mails, &mail_ctx->mail, 1); sync_ctx->space_diff += mail_ctx->mail.space; @@ -851,6 +859,7 @@ sync_ctx->need_space_seq = 0; sync_ctx->space_diff = 0; array_clear(&sync_ctx->mails); + p_clear(sync_ctx->saved_keywords_pool); return 0; } @@ -1289,6 +1298,7 @@ sync_ctx->need_space_seq = 0; array_clear(&sync_ctx->mails); + p_clear(sync_ctx->saved_keywords_pool); } if (sync_ctx->expunged_space > 0) { @@ -1403,6 +1413,7 @@ array_clear(&sync_ctx->mails); array_clear(&sync_ctx->syncs); + p_clear(sync_ctx->saved_keywords_pool); memset(&sync_ctx->sync_rec, 0, sizeof(sync_ctx->sync_rec)); mail_index_sync_reset(sync_ctx->index_sync_ctx); @@ -1538,6 +1549,7 @@ if (sync_ctx->index_sync_ctx != NULL) mail_index_sync_rollback(&sync_ctx->index_sync_ctx); pool_unref(sync_ctx->mail_keyword_pool); + pool_unref(sync_ctx->saved_keywords_pool); str_free(&sync_ctx->header); str_free(&sync_ctx->from_line); array_free(&sync_ctx->mails); @@ -1653,6 +1665,8 @@ sync_ctx.t = mail_index_transaction_begin(sync_view, FALSE, TRUE); sync_ctx.mail_keyword_pool = pool_alloconly_create("mbox keywords", 256); + sync_ctx.saved_keywords_pool = + pool_alloconly_create("mbox saved keywords", 4096); /* make sure we've read the latest keywords in index */ (void)mail_index_get_keywords(mbox->ibox.index);