changeset 5268:debb7be008dc HEAD

We skipped some external transactions that shouldn't have been skipped. The logic for figuring out if flags are unreliable was also a bit broken.
author Timo Sirainen <tss@iki.fi>
date Sat, 10 Mar 2007 19:03:15 +0200
parents 02a4228a921b
children 164190404359
files src/lib-index/mail-index-view-sync.c
diffstat 1 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-view-sync.c	Sat Mar 10 18:14:33 2007 +0200
+++ b/src/lib-index/mail-index-view-sync.c	Sat Mar 10 19:03:15 2007 +0200
@@ -224,6 +224,13 @@
 }
 #endif
 
+#define VIEW_IS_SYNCED_TO_SAME(view, hdr) \
+	((hdr)->log_file_seq == (view)->log_file_seq && \
+	 (hdr)->log_file_int_offset == (view)->log_file_offset && \
+	 (hdr)->log_file_ext_offset == (view)->log_file_offset && \
+	 (!array_is_created(&view->syncs_done) || \
+	  array_count(&view->syncs_done) == 0))
+
 int mail_index_view_sync_begin(struct mail_index_view *view,
                                enum mail_index_sync_type sync_mask,
 			       struct mail_index_view_sync_ctx **ctx_r)
@@ -314,9 +321,7 @@
 				view->map->hdr = *hdr;
 			}
 			ctx->sync_map_ctx.unreliable_flags =
-				!(hdr->log_file_seq == view->log_file_seq &&
-				  hdr->log_file_int_offset ==
-				  view->log_file_offset);
+				!VIEW_IS_SYNCED_TO_SAME(view, hdr);
 
 			/* Copy only the mails that we see currently, since
 			   we're going to append the new ones when we see
@@ -326,8 +331,11 @@
 			view->map->records_count = view->hdr.messages_count;
 
 #ifdef DEBUG
-			if (!ctx->sync_map_ctx.unreliable_flags)
+			if (!ctx->sync_map_ctx.unreliable_flags) {
+				i_assert(view->map->hdr.messages_count ==
+					 view->hdr.messages_count);
 				mail_index_view_check(view);
+			}
 #endif
 		}
 
@@ -385,7 +393,7 @@
 	uint32_t seq;
 	uoff_t offset;
 	int ret;
-	bool skipped, synced_to_map;
+	bool skipped;
 
 	for (;;) {
 		/* Get the next transaction from log. */
@@ -431,15 +439,9 @@
 							       offset);
 		}
 
-		/* view->log_file_offset contains the minimum of
-		   int/ext offsets. */
-		synced_to_map = offset < view->hdr.log_file_ext_offset &&
-			seq == view->hdr.log_file_seq &&
-			(ctx->hdr->type & MAIL_TRANSACTION_EXTERNAL) != 0;
-
 		/* Apply transaction to view's mapping if needed (meaning we
 		   didn't just re-map the view to head mapping). */
-		if (ctx->sync_map_update && !synced_to_map) {
+		if (ctx->sync_map_update) {
 			i_assert((ctx->hdr->type &
 				  MAIL_TRANSACTION_EXPUNGE) == 0);