changeset 5016:874dede81cc1 HEAD

A new "extension introduction" in transaction log could have left some existing views to contain an invalid mapping where it contained the new extension, but with a wrong record_size.
author Timo Sirainen <tss@iki.fi>
date Wed, 17 Jan 2007 16:57:11 +0200
parents aa4ff7a9c3f7
children 987397c331d7
files src/lib-index/mail-index-sync-ext.c
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-sync-ext.c	Wed Jan 17 00:39:49 2007 +0200
+++ b/src/lib-index/mail-index-sync-ext.c	Wed Jan 17 16:57:11 2007 +0200
@@ -381,6 +381,18 @@
 		return 1;
 	}
 
+	if (map->refcount != 1) {
+		/* below we'll first add the extension to the mapping, and then
+		   call sync_ext_reorder() which clones the map. that however
+		   leaves this mapping with the new extension, but without
+		   a resized record_size. if the mapping is still used
+		   elsewhere, it will create problems. so here we'll just make
+		   sure that the partially updated mapping will get destroyed
+		   once the resize is complete. */
+		map = mail_index_map_clone(map, map->hdr.record_size);
+		mail_index_sync_replace_map(ctx, map);
+	}
+
 	hdr_buf = map->hdr_copy_buf;
 	if (MAIL_INDEX_HEADER_SIZE_ALIGN(hdr_buf->used) != hdr_buf->used) {
 		/* we need to add padding between base header and extensions */