dovecot-2.0: lib-index: If keyword is added and remove within tr...

dovecot at dovecot.org dovecot at dovecot.org
Fri Feb 25 10:55:40 EET 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/2762bb5a7481
changeset: 12623:2762bb5a7481
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Feb 25 10:55:34 2011 +0200
description:
lib-index: If keyword is added and remove within transaction, don't write a broken keyword update.
This could have caused "No UID ranges (type=0x400)" errors.

diffstat:

 src/lib-index/mail-index-transaction-export.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (44 lines):

diff -r 2480413a80fb -r 2762bb5a7481 src/lib-index/mail-index-transaction-export.c
--- a/src/lib-index/mail-index-transaction-export.c	Tue Feb 22 15:44:42 2011 +0200
+++ b/src/lib-index/mail-index-transaction-export.c	Fri Feb 25 10:55:34 2011 +0200
@@ -285,10 +285,12 @@
 static void
 log_append_keyword_update(struct mail_index_export_context *ctx,
 			  buffer_t *tmp_buf, enum modify_type modify_type,
-			  const char *keyword, const buffer_t *buffer)
+			  const char *keyword, const buffer_t *uid_buffer)
 {
 	struct mail_transaction_keyword_update kt_hdr;
 
+	i_assert(uid_buffer->used > 0);
+
 	memset(&kt_hdr, 0, sizeof(kt_hdr));
 	kt_hdr.modify_type = modify_type;
 	kt_hdr.name_size = strlen(keyword);
@@ -298,7 +300,7 @@
 	buffer_append(tmp_buf, keyword, kt_hdr.name_size);
 	if ((tmp_buf->used % 4) != 0)
 		buffer_append_zero(tmp_buf, 4 - (tmp_buf->used % 4));
-	buffer_append(tmp_buf, buffer->data, buffer->used);
+	buffer_append(tmp_buf, uid_buffer->data, uid_buffer->used);
 
 	log_append_buffer(ctx, tmp_buf, MAIL_TRANSACTION_KEYWORD_UPDATE);
 }
@@ -320,13 +322,15 @@
 	i_assert(count <= keywords_count);
 
 	for (i = 0; i < count; i++) {
-		if (array_is_created(&updates[i].add_seq)) {
+		if (array_is_created(&updates[i].add_seq) &&
+		    array_count(&updates[i].add_seq) > 0) {
 			change_mask |= MAIL_INDEX_SYNC_TYPE_KEYWORD_ADD;
 			log_append_keyword_update(ctx, tmp_buf,
 					MODIFY_ADD, keywords[i],
 					updates[i].add_seq.arr.buffer);
 		}
-		if (array_is_created(&updates[i].remove_seq)) {
+		if (array_is_created(&updates[i].remove_seq) &&
+		    array_count(&updates[i].remove_seq) > 0) {
 			change_mask |= MAIL_INDEX_SYNC_TYPE_KEYWORD_REMOVE;
 			log_append_keyword_update(ctx, tmp_buf,
 					MODIFY_REMOVE, keywords[i],


More information about the dovecot-cvs mailing list