[dovecot-cvs] dovecot/src/lib-index mail-index-transaction-private.h, 1.32, 1.33 mail-index-transaction-view.c, 1.21, 1.22 mail-index-transaction.c, 1.85, 1.86
tss at dovecot.org
tss at dovecot.org
Tue Mar 6 22:19:11 EET 2007
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv18468
Modified Files:
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.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- mail-index-transaction-private.h 15 Oct 2006 12:59:43 -0000 1.32
+++ mail-index-transaction-private.h 6 Mar 2007 20:19:08 -0000 1.33
@@ -66,6 +66,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_TYPE(seq_array) *array,
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.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- mail-index-transaction-view.c 2 Aug 2006 20:14:19 -0000 1.21
+++ mail-index-transaction-view.c 6 Mar 2007 20:19:08 -0000 1.22
@@ -50,6 +50,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.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- mail-index-transaction.c 22 Jan 2007 15:21:16 -0000 1.85
+++ mail-index-transaction.c 6 Mar 2007 20:19:08 -0000 1.86
@@ -253,8 +253,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;
@@ -262,6 +261,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_modifiable(&t->appends, &count);
new_uid_map = i_new(struct uid_map, count);
@@ -319,6 +321,8 @@
i_free(new_uid_map);
i_free(old_to_new_map);
+
+ t->appends_nonsorted = FALSE;
}
static int _mail_index_transaction_commit(struct mail_index_transaction *t,
@@ -332,8 +336,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