dovecot: Update log_file_head_offset when replacing current sync...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jun 19 16:18:17 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/a8926e90df2a
changeset: 5777:a8926e90df2a
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jun 19 16:18:13 2007 +0300
description:
Update log_file_head_offset when replacing current syncing map.

diffstat:

2 files changed, 27 insertions(+), 26 deletions(-)
src/lib-index/mail-index-sync-private.h |    3 -
src/lib-index/mail-index-sync-update.c  |   50 ++++++++++++++++---------------

diffs (108 lines):

diff -r 5ce403e0ef56 -r a8926e90df2a src/lib-index/mail-index-sync-private.h
--- a/src/lib-index/mail-index-sync-private.h	Tue Jun 19 16:15:01 2007 +0300
+++ b/src/lib-index/mail-index-sync-private.h	Tue Jun 19 16:18:13 2007 +0300
@@ -27,8 +27,7 @@ struct mail_index_sync_map_ctx {
 	uint32_t cur_ext_id;
 
 	uint32_t ext_intro_seq;
-	uoff_t ext_intro_offset;
-	uint32_t ext_intro_size;
+	uoff_t ext_intro_offset, ext_intro_end_offset;
 
 	ARRAY_DEFINE(expunge_handlers, struct mail_index_expunge_handler);
 	ARRAY_DEFINE(extra_contexts, void *);
diff -r 5ce403e0ef56 -r a8926e90df2a src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c	Tue Jun 19 16:15:01 2007 +0300
+++ b/src/lib-index/mail-index-sync-update.c	Tue Jun 19 16:18:13 2007 +0300
@@ -9,7 +9,6 @@
 #include "mail-transaction-log.h"
 #include "mail-transaction-log-private.h"
 
-#if 0 // FIXME: can we / do we want to support this?
 static void
 mail_index_sync_update_log_offset(struct mail_index_sync_map_ctx *ctx,
 				  struct mail_index_map *map, bool eol)
@@ -20,24 +19,31 @@ mail_index_sync_update_log_offset(struct
 	mail_transaction_log_view_get_prev_pos(ctx->view->log_view,
 					       &prev_seq, &prev_offset);
 
-	if (prev_offset == ctx->ext_intro_offset + ctx->ext_intro_size &&
-	    prev_seq == ctx->ext_intro_seq && !eol) {
-		/* previous transaction was an extension introduction.
-		   we probably came here from mail_index_sync_ext_reset().
-		   if there are any more views which want to continue syncing
-		   it needs the intro. so back up a bit more.
-
-		   don't do this in case the last transaction in the log is
-		   the extension intro, so we don't keep trying to sync it
-		   over and over again. */
-		prev_offset = ctx->ext_intro_offset;
-	}
-
-	i_assert(prev_seq == map->hdr.log_file_seq);
-	i_assert(prev_offset >= map->hdr.log_file_head_offset);
+	if (!eol) {
+		i_assert(prev_seq == map->hdr.log_file_seq);
+		i_assert(prev_offset >= map->hdr.log_file_head_offset);
+
+		if (prev_offset == ctx->ext_intro_end_offset &&
+		    prev_seq == ctx->ext_intro_seq) {
+			/* previous transaction was an extension introduction.
+			   we probably came here from
+			   mail_index_sync_ext_reset(). if there are any more
+			   views which want to continue syncing it needs the
+			   intro. so back up a bit more.
+
+			   don't do this in case the last transaction in the
+			   log is the extension intro, so we don't keep trying
+			   to sync it over and over again. */
+			prev_offset = ctx->ext_intro_offset;
+		}
+	} else {
+		i_assert(ctx->view->index->log->head->hdr.file_seq == prev_seq);
+		map->hdr.log_file_seq = prev_seq;
+	}
 	map->hdr.log_file_head_offset = prev_offset;
 }
 
+#if 0 // FIXME: can we / do we want to support this?
 static int
 mail_index_map_msync(struct mail_index *index, struct mail_index_map *map)
 {
@@ -69,11 +75,11 @@ static void mail_index_sync_replace_map(
 
 	i_assert(view->map != map);
 
+	mail_index_sync_update_log_offset(ctx, view->map, FALSE);
 #if 0 // FIXME
 	/* we could have already updated some of the records, so make sure
 	   that other views (in possibly other processes) will see this map's
 	   header in a valid state.  */
-	mail_index_sync_update_log_offset(ctx, view->map, FALSE);
 	(void)mail_index_map_msync(view->index, view->map);
 #endif
 
@@ -489,7 +495,8 @@ int mail_index_sync_record(struct mail_i
 						       &prev_seq, &prev_offset);
 		ctx->ext_intro_seq = prev_seq;
 		ctx->ext_intro_offset = prev_offset;
-		ctx->ext_intro_size = hdr->size + sizeof(*hdr);
+		ctx->ext_intro_end_offset =
+			prev_offset + hdr->size + sizeof(*hdr);
 
 		for (i = 0; i < hdr->size; ) {
 			if (i + sizeof(*rec) > hdr->size) {
@@ -781,12 +788,7 @@ int mail_index_sync_map(struct mail_inde
 	if (had_dirty)
 		mail_index_sync_update_hdr_dirty_flag(map);
 
-	/* update sync position */
-	mail_transaction_log_view_get_prev_pos(view->log_view,
-					       &prev_seq, &prev_offset);
-	i_assert(index->log->head->hdr.file_seq == prev_seq);
-	map->hdr.log_file_seq = prev_seq;
-	map->hdr.log_file_head_offset = prev_offset;
+	mail_index_sync_update_log_offset(&sync_map_ctx, view->map, TRUE);
 
 	/* transaction log tracks internally the current tail offset.
 	   besides using header updates, it also updates the offset to skip


More information about the dovecot-cvs mailing list