dovecot-1.1: mail_index_transaction_get_next_uid() shouldn't sor...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jan 22 01:28:44 EET 2009
details: http://hg.dovecot.org/dovecot-1.1/rev/cfb44ffe34e4
changeset: 8117:cfb44ffe34e4
user: Timo Sirainen <tss at iki.fi>
date: Wed Jan 21 18:28:41 2009 -0500
description:
mail_index_transaction_get_next_uid() shouldn't sort appends. They may still be modified!
Fixes a dbox rebuild bug.
diffstat:
2 files changed, 6 insertions(+), 9 deletions(-)
src/lib-index/mail-index-transaction-private.h | 1 +
src/lib-index/mail-index-transaction.c | 14 +++++---------
diffs (49 lines):
diff -r 42635a268f66 -r cfb44ffe34e4 src/lib-index/mail-index-transaction-private.h
--- a/src/lib-index/mail-index-transaction-private.h Wed Jan 21 16:51:07 2009 -0500
+++ b/src/lib-index/mail-index-transaction-private.h Wed Jan 21 18:28:41 2009 -0500
@@ -37,6 +37,7 @@ struct mail_index_transaction {
mail_index_transaction_reset() to reset it. */
ARRAY_DEFINE(appends, struct mail_index_record);
uint32_t first_new_seq, last_new_seq;
+ uint32_t highest_append_uid;
ARRAY_TYPE(seq_range) expunges;
ARRAY_DEFINE(updates, struct mail_transaction_flag_update);
diff -r 42635a268f66 -r cfb44ffe34e4 src/lib-index/mail-index-transaction.c
--- a/src/lib-index/mail-index-transaction.c Wed Jan 21 16:51:07 2009 -0500
+++ b/src/lib-index/mail-index-transaction.c Wed Jan 21 18:28:41 2009 -0500
@@ -534,8 +534,7 @@ uint32_t mail_index_transaction_get_next
uint32_t mail_index_transaction_get_next_uid(struct mail_index_transaction *t)
{
const struct mail_index_header *head_hdr, *hdr;
- const struct mail_index_record *recs;
- unsigned int count, offset;
+ unsigned int offset;
uint32_t next_uid;
head_hdr = &t->view->index->map->hdr;
@@ -544,13 +543,8 @@ uint32_t mail_index_transaction_get_next
1 : hdr->next_uid;
if (array_is_created(&t->appends)) {
/* get next_uid from appends if they have UIDs */
- mail_index_transaction_sort_appends(t);
-
- recs = array_get(&t->appends, &count);
- if (count > 0 && recs[count-1].uid != 0) {
- i_assert(recs[count-1].uid >= next_uid);
- next_uid = recs[count-1].uid + 1;
- }
+ i_assert(next_uid <= t->highest_append_uid);
+ next_uid = t->highest_append_uid;
}
/* see if it's been updated in pre/post header changes */
@@ -679,6 +673,8 @@ void mail_index_append(struct mail_index
else if (rec->uid == uid)
i_panic("Duplicate UIDs added in transaction");
}
+ if (t->highest_append_uid < uid)
+ t->highest_append_uid = uid;
}
}
More information about the dovecot-cvs
mailing list