[dovecot-cvs] dovecot/src/lib-index mail-index-sync-private.h, 1.1, 1.2 mail-index-sync-update.c, 1.8, 1.9 mail-index-sync.c, 1.6, 1.7 mail-index.h, 1.102, 1.103

cras at procontrol.fi cras at procontrol.fi
Sun May 2 21:07:27 EEST 2004


Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv2133/lib-index

Modified Files:
	mail-index-sync-private.h mail-index-sync-update.c 
	mail-index-sync.c mail-index.h 
Log Message:
Syncing optimizations.



Index: mail-index-sync-private.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-sync-private.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mail-index-sync-private.h	27 Apr 2004 20:25:53 -0000	1.1
+++ mail-index-sync-private.h	2 May 2004 18:07:24 -0000	1.2
@@ -22,7 +22,8 @@
 	unsigned int sync_appends:1;
 };
 
-int mail_index_sync_update_index(struct mail_index_sync_ctx *sync_ctx);
+int mail_index_sync_update_index(struct mail_index_sync_ctx *sync_ctx,
+				 uint32_t sync_stamp, uint64_t sync_size);
 
 void mail_index_header_update_counts(struct mail_index_header *hdr,
 				     uint8_t old_flags, uint8_t new_flags);

Index: mail-index-sync-update.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- mail-index-sync-update.c	29 Apr 2004 12:49:27 -0000	1.8
+++ mail-index-sync-update.c	2 May 2004 18:07:24 -0000	1.9
@@ -166,7 +166,8 @@
 	return 0;
 }
 
-int mail_index_sync_update_index(struct mail_index_sync_ctx *sync_ctx)
+int mail_index_sync_update_index(struct mail_index_sync_ctx *sync_ctx,
+				 uint32_t sync_stamp, uint64_t sync_size)
 {
 	struct mail_index *index = sync_ctx->index;
 	struct mail_index_map *map = index->map;
@@ -177,14 +178,31 @@
 	uint32_t count, file_seq, src_idx, dest_idx;
 	uoff_t file_offset;
 	unsigned int lock_id;
-	int ret;
+	int ret, changed;
 
 	/* rewind */
 	sync_ctx->update_idx = sync_ctx->expunge_idx = 0;
 	sync_ctx->sync_appends =
 		buffer_get_used_size(sync_ctx->appends_buf) != 0;
 
-	if (!mail_index_sync_have_more(sync_ctx)) {
+	changed = mail_index_sync_have_more(sync_ctx);
+
+	memset(&ctx, 0, sizeof(ctx));
+	ctx.index = index;
+	ctx.hdr = *index->hdr;
+	ctx.log_view = sync_ctx->view->log_view;
+
+	/* see if we need to update sync headers */
+	if (ctx.hdr.sync_stamp != sync_stamp && sync_stamp != 0) {
+		ctx.hdr.sync_stamp = sync_stamp;
+		changed = TRUE;
+	}
+	if (ctx.hdr.sync_size != sync_size && sync_size != 0) {
+		ctx.hdr.sync_size = sync_size;
+		changed = TRUE;
+	}
+
+	if (!changed) {
 		/* nothing to sync */
 		return 0;
 	}
@@ -195,11 +213,6 @@
 	if (MAIL_INDEX_MAP_IS_IN_MEMORY(map))
 		map->write_to_disk = TRUE;
 
-	memset(&ctx, 0, sizeof(ctx));
-	ctx.index = index;
-	ctx.hdr = *index->hdr;
-	ctx.log_view = sync_ctx->view->log_view;
-
 	src_idx = dest_idx = 0;
 	append_count = 0; appends = NULL;
 	while (mail_index_sync_next(sync_ctx, &rec) > 0) {

Index: mail-index-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-sync.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mail-index-sync.c	1 May 2004 15:32:24 -0000	1.6
+++ mail-index-sync.c	2 May 2004 18:07:24 -0000	1.7
@@ -176,7 +176,7 @@
 					  index->hdr->log_file_offset,
 					  seq, offset,
 					  MAIL_TRANSACTION_TYPE_MASK) < 0) {
-                mail_index_sync_end(ctx);
+                mail_index_sync_end(ctx, 0, 0);
 		return -1;
 	}
 
@@ -189,7 +189,7 @@
 	ctx->appends_buf = buffer_create_dynamic(default_pool,
 						 1024, (size_t)-1);
 	if (mail_index_sync_read_and_sort(ctx, FALSE) < 0) {
-                mail_index_sync_end(ctx);
+                mail_index_sync_end(ctx, 0, 0);
 		return -1;
 	}
 
@@ -397,7 +397,8 @@
 		ctx->sync_appends;
 }
 
-int mail_index_sync_end(struct mail_index_sync_ctx *ctx)
+int mail_index_sync_end(struct mail_index_sync_ctx *ctx,
+			uint32_t sync_stamp, uint64_t sync_size)
 {
 	const struct mail_index_header *hdr;
 	uint32_t seq;
@@ -420,7 +421,8 @@
 
 	if (ret == 0) {
 		mail_index_sync_read_and_sort(ctx, TRUE);
-		if (mail_index_sync_update_index(ctx) < 0)
+		if (mail_index_sync_update_index(ctx, sync_stamp,
+						 sync_size) < 0)
 			ret = -1;
 	}
 

Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- mail-index.h	1 May 2004 16:42:10 -0000	1.102
+++ mail-index.h	2 May 2004 18:07:24 -0000	1.103
@@ -33,13 +33,8 @@
 };
 
 enum mail_index_header_flag {
-	/* Corrupted-flag should be set while anything dangerous is done to
-	   index file, such as when expunging messages. Once the operation
-	   is finished, the corrupted-flag is removed. If this flag is noticed
-	   unexpectedly, the index must be assumed to be corrupted and must
-	   not be used. */
-	MAIL_INDEX_HDR_FLAG_CORRUPTED		= 0x0001,
-	MAIL_INDEX_HDR_FLAG_COMPRESS_CACHE	= 0x0002
+	/* Index file is corrupted, reopen or recreate it. */
+	MAIL_INDEX_HDR_FLAG_CORRUPTED		= 0x0001
 };
 
 enum mail_index_record_flag {
@@ -209,8 +204,10 @@
 			 struct mail_index_sync_rec *sync_rec);
 /* Returns 1 if there's more to sync, 0 if not. */
 int mail_index_sync_have_more(struct mail_index_sync_ctx *ctx);
-/* End synchronization by unlocking the index and closing the view. */
-int mail_index_sync_end(struct mail_index_sync_ctx *ctx);
+/* End synchronization by unlocking the index and closing the view.
+   sync_stamp/sync_size in header is updated to given values. */
+int mail_index_sync_end(struct mail_index_sync_ctx *ctx,
+			uint32_t sync_stamp, uint64_t sync_size);
 
 /* Mark index file corrupted. Invalidates all views. */
 void mail_index_mark_corrupted(struct mail_index *index);



More information about the dovecot-cvs mailing list