[dovecot-cvs] dovecot/src/lib-index mail-index-sync-update.c, 1.114, 1.115 mail-index-view-sync.c, 1.64, 1.65

tss at dovecot.org tss at dovecot.org
Sat Mar 10 20:48:52 EET 2007


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

Modified Files:
	mail-index-sync-update.c mail-index-view-sync.c 
Log Message:
View syncing fixes.



Index: mail-index-sync-update.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- mail-index-sync-update.c	10 Mar 2007 18:25:25 -0000	1.114
+++ mail-index-sync-update.c	10 Mar 2007 18:48:49 -0000	1.115
@@ -35,9 +35,11 @@
 		prev_offset = ctx->ext_intro_offset;
 	}
 
-	if (!ctx->sync_only_external)
+	if (!ctx->sync_only_external) {
+		i_assert(prev_offset >= map->hdr.log_file_int_offset ||
+			 prev_seq > map->hdr.log_file_seq);
 		map->hdr.log_file_int_offset = prev_offset;
-	else if (map->hdr.log_file_seq != prev_seq) {
+	} else if (map->hdr.log_file_seq != prev_seq) {
 		/* log sequence changed. update internal offset to
 		   beginning of the new file. */
 		i_assert(map->hdr.log_file_int_offset ==
@@ -45,8 +47,17 @@
 		map->hdr.log_file_int_offset =
 			ctx->view->index->log->head->hdr.hdr_size;
 	}
-	map->hdr.log_file_seq = prev_seq;
-	map->hdr.log_file_ext_offset = prev_offset;
+
+	/* we might be in the middle of syncing internal transactions, with
+	   some of the following external transactions already synced. */
+	i_assert(prev_seq > map->hdr.log_file_seq ||
+		 prev_offset >= map->hdr.log_file_ext_offset ||
+		 (!eol && !ctx->sync_only_external));
+	if (map->hdr.log_file_seq != prev_seq ||
+	    prev_offset > map->hdr.log_file_ext_offset) {
+		map->hdr.log_file_seq = prev_seq;
+		map->hdr.log_file_ext_offset = prev_offset;
+	}
 }
 
 static int

Index: mail-index-view-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-view-sync.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- mail-index-view-sync.c	10 Mar 2007 18:46:56 -0000	1.64
+++ mail-index-view-sync.c	10 Mar 2007 18:48:49 -0000	1.65
@@ -395,7 +395,7 @@
 	uint32_t seq;
 	uoff_t offset;
 	int ret;
-	bool skipped;
+	bool skipped, synced_to_map;
 
 	for (;;) {
 		/* Get the next transaction from log. */
@@ -441,6 +441,15 @@
 							       offset);
 		}
 
+		/* if we started from a map that we didn't create ourself,
+		   some of the external transactions may already be synced.
+		   at the end of view sync we'll update the ext_offset in the
+		   header so that this check always becomes FALSE for
+		   subsequent syncs. */
+		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) {
@@ -635,6 +644,13 @@
 		view->map = view->sync_new_map;
 		view->sync_new_map = NULL;
 	}
+
+	if (ctx->sync_map_update) {
+		view->map->hdr.log_file_seq = view->log_file_seq;
+		view->map->hdr.log_file_int_offset =
+			view->map->hdr.log_file_ext_offset =
+			view->log_file_offset;
+	}
 	view->hdr = view->map->hdr;
 
 #ifdef DEBUG



More information about the dovecot-cvs mailing list