[dovecot-cvs] dovecot/src/lib-index mail-index-transaction-private.h, 1.29, 1.29.2.1 mail-index-transaction-view.c, 1.16.2.2, 1.16.2.3 mail-index-transaction.c, 1.76.2.2, 1.76.2.3
tss at dovecot.org
tss at dovecot.org
Tue Mar 6 22:19:08 EET 2007
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv18473
Modified Files:
Tag: branch_1_0
mail-index-transaction-private.h mail-index-transaction-view.c
mail-index-transaction.c
Log Message:
When adding mails to index in non-sorted UID order and then using
mail_index_get_header(), the next_uid field could have been wrong.
Index: mail-index-transaction-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-transaction-private.h,v
retrieving revision 1.29
retrieving revision 1.29.2.1
diff -u -d -r1.29 -r1.29.2.1
--- mail-index-transaction-private.h 15 Jan 2006 00:11:36 -0000 1.29
+++ mail-index-transaction-private.h 6 Mar 2007 20:19:05 -0000 1.29.2.1
@@ -49,6 +49,8 @@
void mail_index_transaction_ref(struct mail_index_transaction *t);
void mail_index_transaction_unref(struct mail_index_transaction **t);
+void mail_index_transaction_sort_appends(struct mail_index_transaction *t);
+
bool mail_index_seq_array_lookup(const array_t *buffer, uint32_t seq,
unsigned int *idx_r);
Index: mail-index-transaction-view.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-transaction-view.c,v
retrieving revision 1.16.2.2
retrieving revision 1.16.2.3
diff -u -d -r1.16.2.2 -r1.16.2.3
--- mail-index-transaction-view.c 2 Aug 2006 20:14:18 -0000 1.16.2.2
+++ mail-index-transaction-view.c 6 Mar 2007 20:19:05 -0000 1.16.2.3
@@ -48,6 +48,8 @@
if (array_is_created(&tview->t->appends)) {
/* update next_uid from appends, if UIDs have been given yet */
+ mail_index_transaction_sort_appends(tview->t);
+
recs = array_get(&tview->t->appends, &count);
if (count > 0 && recs[count-1].uid != 0) {
i_assert(recs[count-1].uid >= hdr->next_uid);
Index: mail-index-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-transaction.c,v
retrieving revision 1.76.2.2
retrieving revision 1.76.2.3
diff -u -d -r1.76.2.2 -r1.76.2.3
--- mail-index-transaction.c 22 Jan 2007 15:21:12 -0000 1.76.2.2
+++ mail-index-transaction.c 6 Mar 2007 20:19:05 -0000 1.76.2.3
@@ -283,8 +283,7 @@
(m1->uid > m2->uid ? 1 : 0);
}
-static void
-mail_index_transaction_sort_appends(struct mail_index_transaction *t)
+void mail_index_transaction_sort_appends(struct mail_index_transaction *t)
{
struct mail_index_record *recs, *sorted_recs;
struct uid_map *new_uid_map;
@@ -292,6 +291,9 @@
uint32_t *old_to_new_map;
unsigned int i, j, count, ext_rec_array_count;
+ if (!t->appends_nonsorted)
+ return;
+
/* first make a copy of the UIDs and map them to sequences */
recs = array_get_modifyable(&t->appends, &count);
new_uid_map = i_new(struct uid_map, count);
@@ -350,6 +352,8 @@
i_free(new_uid_map);
i_free(old_to_new_map);
+
+ t->appends_nonsorted = FALSE;
}
int mail_index_transaction_commit(struct mail_index_transaction **_t,
@@ -369,8 +373,7 @@
t->cache_trans_ctx = NULL;
}
- if (t->appends_nonsorted)
- mail_index_transaction_sort_appends(t);
+ mail_index_transaction_sort_appends(t);
if (mail_index_transaction_convert_to_uids(t) < 0)
ret = -1;
More information about the dovecot-cvs
mailing list