[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync-private.h, 1.58, 1.59 mbox-sync.c, 1.187, 1.188
tss at dovecot.org
tss at dovecot.org
Thu Oct 26 01:17:27 UTC 2006
Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv10385
Modified Files:
mbox-sync-private.h mbox-sync.c
Log Message:
Last keyword pool clearing optimization broke the keywords if we had to move
mails around in the file.
Index: mbox-sync-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-private.h,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- mbox-sync-private.h 15 Oct 2006 22:47:50 -0000 1.58
+++ mbox-sync-private.h 26 Oct 2006 00:17:23 -0000 1.59
@@ -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;
Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -d -r1.187 -r1.188
--- mbox-sync.c 15 Oct 2006 22:47:50 -0000 1.187
+++ mbox-sync.c 26 Oct 2006 00:17:23 -0000 1.188
@@ -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);
More information about the dovecot-cvs
mailing list