dovecot-1.3: dbox: Saving shouldn't give up so easily in using e...

dovecot at dovecot.org dovecot at dovecot.org
Sat Apr 11 01:55:22 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.3/rev/c5ba9bc89ccb
changeset: 9071:c5ba9bc89ccb
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Apr 10 18:55:18 2009 -0400
description:
dbox: Saving shouldn't give up so easily in using existing files.

diffstat:

1 file changed, 6 insertions(+), 4 deletions(-)
src/lib-storage/index/dbox/dbox-map.c |   10 ++++++----

diffs (37 lines):

diff -r 8217998f8133 -r c5ba9bc89ccb src/lib-storage/index/dbox/dbox-map.c
--- a/src/lib-storage/index/dbox/dbox-map.c	Fri Apr 10 18:50:35 2009 -0400
+++ b/src/lib-storage/index/dbox/dbox-map.c	Fri Apr 10 18:55:18 2009 -0400
@@ -712,10 +712,11 @@ dbox_map_find_appendable_file(struct dbo
 {
 	struct dbox_map *map = ctx->map;
 	const struct dbox_settings *set = map->storage->set;
+	ARRAY_TYPE(seq_range) checked_file_ids;
 	struct dbox_file *const *files;
 	const struct mail_index_header *hdr;
 	unsigned int i, count, backwards_lookup_count;
-	uint32_t seq, seq1, uid, file_id, min_seen_file_id;
+	uint32_t seq, seq1, uid, file_id;
 	uoff_t offset, append_offset, size;
 	time_t stamp;
 	bool retry_later;
@@ -759,16 +760,17 @@ dbox_map_find_appendable_file(struct dbo
 	/* try to find an existing appendable file */
 	stamp = day_begin_stamp(set->dbox_rotate_days);
 	hdr = mail_index_get_header(map->view);
-	min_seen_file_id = (uint32_t)-1;
 
 	ctx->orig_next_uid = hdr->next_uid;
 	backwards_lookup_count = 0;
+	t_array_init(&checked_file_ids, 16);
 	for (seq = hdr->messages_count; seq > 0; seq--) {
 		if (dbox_map_lookup_seq(map, seq, &file_id, &offset, &size) < 0)
 			return -1;
-		if (file_id >= min_seen_file_id)
+
+		if (seq_range_exists(&checked_file_ids, file_id))
 			continue;
-		min_seen_file_id = file_id;
+		seq_range_array_add(&checked_file_ids, 0, file_id);
 
 		if (++backwards_lookup_count > MAX_BACKWARDS_LOOKUPS) {
 			/* we've wasted enough time here */


More information about the dovecot-cvs mailing list