changeset 5020:ac2be98ea811 HEAD

unreliable_flags wasn't always set correctly, which caused "xxx counter wrong" errors and such.
author Timo Sirainen <tss@iki.fi>
date Wed, 17 Jan 2007 20:47:46 +0200
parents 595dcb33802f
children 623ed4a5339b
files src/lib-index/mail-index-view-sync.c
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-view-sync.c	Wed Jan 17 20:45:43 2007 +0200
+++ b/src/lib-index/mail-index-view-sync.c	Wed Jan 17 20:47:46 2007 +0200
@@ -260,16 +260,22 @@
 		uint32_t old_records_count = view->map->records_count;
 
 		if (view->map != view->index->map) {
+			const struct mail_index_header *hdr;
+
 			/* Using non-head mapping. We have to apply
 			   transactions to it to get latest changes into it. */
 			ctx->sync_map_update = TRUE;
+
 			/* Unless map was synced at the exact same position as
 			   view, the message flags can't be reliably used to
-			   update flag counters. */
+			   update flag counters. note that map->hdr may contain
+			   old information if another process updated the
+			   index file since. */
+			hdr = view->map->mmap_base != NULL ?
+				view->map->mmap_base : &view->map->hdr;
 			ctx->sync_map_ctx.unreliable_flags =
-				!(view->map->hdr.log_file_seq ==
-				  view->log_file_seq &&
-				  view->map->hdr.log_file_int_offset ==
+				!(hdr->log_file_seq == view->log_file_seq &&
+				  hdr->log_file_int_offset ==
 				  view->log_file_offset);
 
 			/* Copy only the mails that we see currently, since