[dovecot-cvs] dovecot/src/lib-index mail-index-view-sync.c, 1.56, 1.57 mail-index.h, 1.161, 1.162

tss at dovecot.org tss at dovecot.org
Sun Oct 15 18:56:14 UTC 2006


Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv25630/lib-index

Modified Files:
	mail-index-view-sync.c mail-index.h 
Log Message:
Try to avoid sending duplicate/useless flag updates.



Index: mail-index-view-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-view-sync.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- mail-index-view-sync.c	10 Sep 2006 12:48:18 -0000	1.56
+++ mail-index-view-sync.c	15 Oct 2006 17:56:09 -0000	1.57
@@ -12,7 +12,7 @@
 	struct mail_index_view *view;
 	enum mail_transaction_type visible_sync_mask;
 	struct mail_index_sync_map_ctx sync_map_ctx;
-	ARRAY_TYPE(uid_range) expunges;
+	ARRAY_TYPE(seq_range) expunges;
 
 	const struct mail_transaction_header *hdr;
 	const void *data;
@@ -24,11 +24,12 @@
 };
 
 static void
-mail_transaction_log_sort_expunges(ARRAY_TYPE(uid_range) *expunges,
-				   const struct uid_range *src, size_t src_size)
+mail_transaction_log_sort_expunges(ARRAY_TYPE(seq_range) *expunges,
+				   const struct seq_range *src, size_t src_size)
 {
-	const struct uid_range *src_end;
-	struct uid_range *dest, new_exp;
+	/* Note that all the sequences are actually still UIDs at this point */
+	const struct seq_range *src_end;
+	struct seq_range *dest, new_exp;
 	unsigned int first, i, dest_count;
 
 	i_assert(src_size % sizeof(*src) == 0);
@@ -43,28 +44,28 @@
 	src_end = CONST_PTR_OFFSET(src, src_size);
 	for (i = 0; src != src_end; src++) {
 		/* src[] must be sorted. */
-		i_assert(src+1 == src_end || src->uid2 < src[1].uid1);
-		i_assert(src->uid1 <= src->uid2);
+		i_assert(src+1 == src_end || src->seq2 < src[1].seq1);
+		i_assert(src->seq1 <= src->seq2);
 
 		for (; i < dest_count; i++) {
-			if (src->uid1 < dest[i].uid1)
+			if (src->seq1 < dest[i].seq1)
 				break;
 		}
 
 		new_exp = *src;
 
 		first = i;
-		while (i < dest_count && src->uid2 >= dest[i].uid1-1) {
+		while (i < dest_count && src->seq2 >= dest[i].seq1-1) {
 			/* we can/must merge with next record */
-			if (new_exp.uid2 < dest[i].uid2)
-				new_exp.uid2 = dest[i].uid2;
+			if (new_exp.seq2 < dest[i].seq2)
+				new_exp.seq2 = dest[i].seq2;
 			i++;
 		}
 
-		if (first > 0 && new_exp.uid1 <= dest[first-1].uid2+1) {
+		if (first > 0 && new_exp.seq1 <= dest[first-1].seq2+1) {
 			/* continue previous record */
-			if (dest[first-1].uid2 < new_exp.uid2)
-				dest[first-1].uid2 = new_exp.uid2;
+			if (dest[first-1].seq2 < new_exp.seq2)
+				dest[first-1].seq2 = new_exp.seq2;
 		} else if (i == first) {
 			array_insert(expunges, i, &new_exp, 1);
 			i++; first++;
@@ -112,10 +113,10 @@
 
 static int
 view_sync_get_expunges(struct mail_index_view *view,
-		       ARRAY_TYPE(uid_range) *expunges_r)
+		       ARRAY_TYPE(seq_range) *expunges_r)
 {
 	const struct mail_transaction_header *hdr;
-	struct uid_range *src, *src_end, *dest;
+	struct seq_range *src, *src_end, *dest;
 	const void *data;
 	unsigned int count;
 	int ret;
@@ -135,17 +136,17 @@
 		return -1;
 	}
 
-	/* convert to sequences */
+	/* convert UIDs to sequences */
 	src = dest = array_get_modifiable(expunges_r, &count);
 	src_end = src + count;
 	for (; src != src_end; src++) {
-		ret = mail_index_lookup_uid_range(view, src->uid1,
-						  src->uid2,
-						  &dest->uid1,
-						  &dest->uid2);
+		ret = mail_index_lookup_uid_range(view, src->seq1,
+						  src->seq2,
+						  &dest->seq1,
+						  &dest->seq2);
 		i_assert(ret == 0);
 
-		if (dest->uid1 == 0)
+		if (dest->seq1 == 0)
 			count--;
 		else
 			dest++;
@@ -195,7 +196,7 @@
 	struct mail_index_view_sync_ctx *ctx;
 	struct mail_index_map *map;
 	enum mail_transaction_type log_get_mask, visible_mask;
-	ARRAY_TYPE(uid_range) expunges = ARRAY_INIT;
+	ARRAY_TYPE(seq_range) expunges = ARRAY_INIT;
 
 	/* We must sync flags as long as view is mmap()ed, as the flags may
 	   have already changed under us. */
@@ -511,14 +512,10 @@
 	return 1;
 }
 
-const uint32_t *
-mail_index_view_sync_get_expunges(struct mail_index_view_sync_ctx *ctx,
-				  unsigned int *count_r)
+void mail_index_view_sync_get_expunges(struct mail_index_view_sync_ctx *ctx,
+				       const ARRAY_TYPE(seq_range) **expunges_r)
 {
-	const struct uid_range *data;
-
-	data = array_get(&ctx->expunges, count_r);
-	return (const uint32_t *)data;
+	*expunges_r = &ctx->expunges;
 }
 
 static void

Index: mail-index.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -d -r1.161 -r1.162
--- mail-index.h	13 Oct 2006 15:22:15 -0000	1.161
+++ mail-index.h	15 Oct 2006 17:56:10 -0000	1.162
@@ -2,6 +2,7 @@
 #define __MAIL_INDEX_H
 
 #include "mail-types.h"
+#include "seq-range-array.h"
 
 #define MAIL_INDEX_MAJOR_VERSION 7
 #define MAIL_INDEX_MINOR_VERSION 0
@@ -266,9 +267,9 @@
 /* Returns -1 if error, 0 if sync is finished, 1 if record was filled. */
 int mail_index_view_sync_next(struct mail_index_view_sync_ctx *ctx,
 			      struct mail_index_view_sync_rec *sync_rec);
-const uint32_t *
+void
 mail_index_view_sync_get_expunges(struct mail_index_view_sync_ctx *ctx,
-				 unsigned int *count_r);
+				  const ARRAY_TYPE(seq_range) **expunges_r);
 void mail_index_view_sync_end(struct mail_index_view_sync_ctx **ctx);
 
 /* Returns the index header. */



More information about the dovecot-cvs mailing list