[dovecot-cvs] dovecot/src/lib-index mail-index-sync-private.h, 1.34, 1.35 mail-index-sync-update.c, 1.112, 1.113

tss at dovecot.org tss at dovecot.org
Fri Mar 9 23:17:12 EET 2007


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

Modified Files:
	mail-index-sync-private.h mail-index-sync-update.c 
Log Message:
Don't set log sync position right after extension introduction, unless it's
at the end of the file. This should fix some "Extension reset without intro
prefix" errors.



Index: mail-index-sync-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-private.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- mail-index-sync-private.h	23 Jan 2007 16:10:58 -0000	1.34
+++ mail-index-sync-private.h	9 Mar 2007 21:17:10 -0000	1.35
@@ -46,6 +46,10 @@
 	struct mail_index_view *view;
 	uint32_t cur_ext_id;
 
+	uint32_t ext_intro_seq;
+	uoff_t ext_intro_offset;
+	uint32_t ext_intro_size;
+
 	ARRAY_DEFINE(expunge_handlers, struct mail_index_expunge_handler);
 	ARRAY_DEFINE(extra_contexts, void *);
 

Index: mail-index-sync-update.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- mail-index-sync-update.c	6 Mar 2007 19:51:24 -0000	1.112
+++ mail-index-sync-update.c	9 Mar 2007 21:17:10 -0000	1.113
@@ -14,7 +14,7 @@
 
 static void
 mail_index_sync_update_log_offset(struct mail_index_sync_map_ctx *ctx,
-				  struct mail_index_map *map)
+				  struct mail_index_map *map, bool eol)
 {
 	uint32_t prev_seq;
 	uoff_t prev_offset;
@@ -22,6 +22,19 @@
 	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;
+	}
+
 	if (!ctx->sync_only_external)
 		map->hdr.log_file_int_offset = prev_offset;
 	else if (map->hdr.log_file_seq != prev_seq && map == ctx->view->map) {
@@ -94,7 +107,7 @@
 	/* some views may still use the same mapping, and since we could have
 	   already updated the records, make sure we leave the header in a
 	   valid state as well */
-	mail_index_sync_update_log_offset(ctx, old_map);
+	mail_index_sync_update_log_offset(ctx, old_map, FALSE);
 	(void)mail_index_map_msync(view->index, old_map);
 	mail_index_unmap(view->index, &old_map);
 
@@ -613,6 +626,14 @@
 	case MAIL_TRANSACTION_EXT_INTRO: {
 		const struct mail_transaction_ext_intro *rec = data;
 		unsigned int i;
+		uint32_t prev_seq;
+		uoff_t prev_offset;
+
+		mail_transaction_log_view_get_prev_pos(ctx->view->log_view,
+						       &prev_seq, &prev_offset);
+		ctx->ext_intro_seq = prev_seq;
+		ctx->ext_intro_offset = prev_offset;
+		ctx->ext_intro_size = hdr->size + sizeof(*hdr);
 
 		for (i = 0; i < hdr->size; ) {
 			if (i + sizeof(*rec) > hdr->size) {
@@ -851,8 +872,10 @@
 		map = NULL;
 	}
 
-	if (ret == 0)
-		mail_index_sync_update_log_offset(&sync_map_ctx, view->map);
+	if (ret == 0) {
+		mail_index_sync_update_log_offset(&sync_map_ctx, view->map,
+						  TRUE);
+	}
 	mail_index_sync_map_deinit(&sync_map_ctx);
 
 	index->sync_update = FALSE;



More information about the dovecot-cvs mailing list