dovecot: Expunge fixes

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 9 15:11:28 EET 2008


details:   http://hg.dovecot.org/dovecot/rev/21d1d0ced13e
changeset: 7220:21d1d0ced13e
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Feb 09 15:11:24 2008 +0200
description:
Expunge fixes

diffstat:

2 files changed, 15 insertions(+), 14 deletions(-)
src/plugins/fts-squat/squat-trie.c    |   20 ++++++++++----------
src/plugins/fts-squat/squat-uidlist.c |    9 +++++----

diffs (101 lines):

diff -r 6c48b72c5096 -r 21d1d0ced13e src/plugins/fts-squat/squat-trie.c
--- a/src/plugins/fts-squat/squat-trie.c	Sat Feb 09 14:34:30 2008 +0200
+++ b/src/plugins/fts-squat/squat-trie.c	Sat Feb 09 15:11:24 2008 +0200
@@ -1065,10 +1065,8 @@ squat_trie_iterate_next(struct squat_tri
 	}
 
 	*shifts_r = ctx->cur.shifts;
-	if (array_is_created(&ctx->cur.shifts)) {
+	if (array_is_created(&ctx->cur.shifts))
 		shift_count = array_count(&ctx->cur.shifts);
-		i_assert(shift_count > 0);
-	}
 
 	children = NODE_CHILDREN_NODES(ctx->cur.node);
 	while (children[ctx->cur.idx++].uid_list_idx == 0) {
@@ -1082,6 +1080,8 @@ squat_trie_iterate_next(struct squat_tri
 	ctx->cur.idx = 0;
 	if (shift_count != 0)
 		i_array_init(&ctx->cur.shifts, shift_count);
+	else
+		memset(&ctx->cur.shifts, 0, sizeof(ctx->cur.shifts));
 	return squat_trie_iterate_first(ctx);
 }
 
@@ -1096,6 +1096,9 @@ squat_uidlist_update_expunged_uids(const
 	unsigned int i, uid_idx, uid_count, shift_count;
 	uint32_t child_shift_seq1, child_shift_count, seq_high;
 	unsigned int shift_sum = 0, child_sum = 0;
+
+	if (!array_is_created(shifts_arr))
+		return;
 
 	uids = array_get_modifiable(uids_arr, &uid_count);
 	shifts = array_get(shifts_arr, &shift_count);
@@ -1122,11 +1125,9 @@ squat_uidlist_update_expunged_uids(const
 				uid_idx++;
 			}
 		}
-		if (uid_idx == uid_count) {
-			i_assert(array_count(child_shifts) > 0 ||
-				 array_count(uids_arr) == 0);
+		if (uid_idx == uid_count)
 			break;
-		}
+
 		shift.seq1 = I_MAX(shifts[i].seq1, seq_high);
 		shift.seq2 = shifts[i].seq2;
 		if (shift.seq2 < uids[uid_idx].seq1) {
@@ -1206,7 +1207,7 @@ squat_trie_expunge_uidlists(struct squat
 	i_array_init(&shifts, array_count(expunged_uids));
 	array_append_array(&shifts, expunged_uids);
 
-	while (node != NULL) {
+	do {
 		i_assert(node->uid_list_idx != 0);
 		array_clear(&uid_range);
 		if (squat_uidlist_get_seqrange(ctx->trie->uidlist,
@@ -1224,9 +1225,8 @@ squat_trie_expunge_uidlists(struct squat
 			node->next_uid = 0;
 		}
 		node = squat_trie_iterate_next(iter, &shifts);
-		i_assert(array_count(&shifts) > 0);
 		shift = TRUE;
-	}
+	} while (node != NULL);
 	array_free(&uid_range);
 	return ret;
 }
diff -r 6c48b72c5096 -r 21d1d0ced13e src/plugins/fts-squat/squat-uidlist.c
--- a/src/plugins/fts-squat/squat-uidlist.c	Sat Feb 09 14:34:30 2008 +0200
+++ b/src/plugins/fts-squat/squat-uidlist.c	Sat Feb 09 15:11:24 2008 +0200
@@ -693,6 +693,7 @@ uidlist_write_block_list_and_header(stru
 
 	if (array_count(block_end_indexes) == 0) {
 		ctx->build_hdr.used_file_size = output->offset;
+		ctx->build_hdr.block_list_offset = 0;
 		uidlist->hdr = ctx->build_hdr;
 		return;
 	}
@@ -940,10 +941,6 @@ uint32_t squat_uidlist_rebuild_nextu(str
 	if (count == 0)
 		return 0;
 
-	if (count == 1 && range[0].seq1 == range[0].seq2) {
-		/* single UID */
-		return (range[0].seq1 << 1) | 1;
-	}
 	if (range[count-1].seq2 < 8) {
 		/* we can use a singleton bitmask */
 		ret = 0;
@@ -952,6 +949,10 @@ uint32_t squat_uidlist_rebuild_nextu(str
 				ret |= 1 << (seq+1);
 		}
 		return ret;
+	}
+	if (count == 1 && range[0].seq1 == range[0].seq2) {
+		/* single UID */
+		return (range[0].seq1 << 1) | 1;
 	}
 
 	/* convert seq range to our internal representation and use the


More information about the dovecot-cvs mailing list