[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync.c, 1.8, 1.9

cras at procontrol.fi cras at procontrol.fi
Mon May 24 04:50:19 EEST 2004


Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv13926/lib-storage/index/mbox

Modified Files:
	mbox-sync.c 
Log Message:
Index header changes now go through transaction log. Removed the kludgy
parameters for mail_index_sync_end(). Removed code duplication of syncing
index root mapping and view mapping. Some fixes to handling uidvalidity and
nextuid in syncing.



Index: mbox-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- a/mbox-sync.c	23 May 2004 01:58:32 -0000	1.8
+++ b/mbox-sync.c	24 May 2004 01:50:17 -0000	1.9
@@ -57,6 +57,7 @@
 #include "mbox-lock.h"
 #include "mbox-sync-private.h"
 
+#include <stddef.h>
 #include <sys/stat.h>
 
 static int mbox_sync_grow_file(struct mbox_sync_context *sync_ctx,
@@ -378,17 +379,6 @@
 		}
 	}
 
-	if (ret < 0)
-		mail_index_transaction_rollback(t);
-	else {
-		if (mail_index_transaction_commit(t, &seq, &offset) < 0)
-			ret = -1;
-		else if (seq != 0) {
-			ibox->commit_log_file_seq = seq;
-			ibox->commit_log_file_offset = offset;
-		}
-	}
-
 	if (ret == 0) {
 		if (fstat(ibox->mbox_fd, &st) < 0) {
 			mbox_set_syscall_error(ibox, "fstat()");
@@ -400,9 +390,36 @@
 		st.st_size = 0;
 	}
 
+	if (mail_index_get_header(sync_view, &hdr) < 0)
+		ret = -1;
+	if ((uint32_t)st.st_mtime != hdr->sync_stamp) {
+		uint32_t sync_stamp = st.st_mtime;
+
+		mail_index_update_header(t,
+			offsetof(struct mail_index_header, sync_stamp),
+			&sync_stamp, sizeof(sync_stamp));
+	}
+	if ((uint64_t)st.st_mtime != hdr->sync_size) {
+		uint64_t sync_size = st.st_size;
+
+		mail_index_update_header(t,
+			offsetof(struct mail_index_header, sync_size),
+			&sync_size, sizeof(sync_size));
+	}
+
+	if (ret < 0)
+		mail_index_transaction_rollback(t);
+	else {
+		if (mail_index_transaction_commit(t, &seq, &offset) < 0)
+			ret = -1;
+		else if (seq != 0) {
+			ibox->commit_log_file_seq = seq;
+			ibox->commit_log_file_offset = offset;
+		}
+	}
+
 	if (ret != -2) {
-		if (mail_index_sync_end(index_sync_ctx,
-					st.st_mtime, st.st_size) < 0)
+		if (mail_index_sync_end(index_sync_ctx) < 0)
 			ret = -1;
 	}
 
@@ -463,7 +480,7 @@
 			}
 		}
 	} else {
-		(void)mail_index_sync_end(index_sync_ctx, 0, 0);
+		(void)mail_index_sync_end(index_sync_ctx);
 		ret = -1;
 	}
 



More information about the dovecot-cvs mailing list