[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-storage.c, 1.98, 1.99 mbox-sync-private.h, 1.33, 1.34 mbox-sync.c, 1.89, 1.90 mbox-transaction.c, 1.7, 1.8

cras at dovecot.org cras at dovecot.org
Fri Sep 24 14:47:32 EEST 2004


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

Modified Files:
	mbox-storage.c mbox-sync-private.h mbox-sync.c 
	mbox-transaction.c 
Log Message:
Split sync_flag_full into sync_flag_full_read and _write. Closing mailbox
now always writes changes.



Index: mbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -d -r1.98 -r1.99
--- mbox-storage.c	11 Sep 2004 12:17:53 -0000	1.98
+++ mbox-storage.c	24 Sep 2004 11:47:30 -0000	1.99
@@ -9,6 +9,7 @@
 #include "mbox-storage.h"
 #include "mbox-lock.h"
 #include "mbox-file.h"
+#include "mbox-sync-private.h"
 #include "mail-copy.h"
 
 #include <stdio.h>
@@ -788,10 +789,21 @@
 static int mbox_storage_close(struct mailbox *box)
 {
 	struct index_mailbox *ibox = (struct index_mailbox *)box;
+	const struct mail_index_header *hdr;
+	int ret;
+
+	ret = mail_index_get_header(ibox->view, &hdr);
+	if (ret == 0 && (hdr->flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0 &&
+	    !ibox->readonly && !ibox->mbox_readonly) {
+		/* we've done changes to mbox which haven't been written yet.
+		   do it now. */
+		if (mbox_sync(ibox, MBOX_SYNC_REWRITE) < 0)
+			ret = -1;
+	}
 
         mbox_file_close(ibox);
         index_storage_mailbox_free(box);
-	return 0;
+	return ret;
 }
 
 static void

Index: mbox-sync-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-private.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- mbox-sync-private.h	23 Sep 2004 22:29:13 -0000	1.33
+++ mbox-sync-private.h	24 Sep 2004 11:47:30 -0000	1.34
@@ -8,7 +8,8 @@
 	MBOX_SYNC_LAST_COMMIT	= 0x01,
 	MBOX_SYNC_HEADER	= 0x02,
 	MBOX_SYNC_LOCK_READING	= 0x04,
-	MBOX_SYNC_UNDIRTY	= 0x08
+	MBOX_SYNC_UNDIRTY	= 0x08,
+	MBOX_SYNC_REWRITE	= 0x10
 };
 
 struct mbox_flag_type {

Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- mbox-sync.c	24 Sep 2004 11:18:50 -0000	1.89
+++ mbox-sync.c	24 Sep 2004 11:47:30 -0000	1.90
@@ -407,7 +407,7 @@
 
 		if (mail_ctx->dirty)
 			mbox_flags |= MAIL_INDEX_MAIL_FLAG_DIRTY;
-		else if ((sync_ctx->flags & MBOX_SYNC_UNDIRTY) != 0)
+		else if (!sync_ctx->delay_writes)
 			mbox_flags &= ~MAIL_INDEX_MAIL_FLAG_DIRTY;
 
 		if ((idx_flags & ~MAIL_INDEX_MAIL_FLAG_DIRTY) ==
@@ -1316,7 +1316,8 @@
 	sync_ctx.fd = sync_ctx.ibox->mbox_fd;
 	sync_ctx.flags = flags;
 	sync_ctx.delay_writes = sync_ctx.ibox->mbox_readonly ||
-		((flags & MBOX_SYNC_UNDIRTY) == 0 &&
+		sync_ctx.ibox->readonly ||
+		((flags & MBOX_SYNC_REWRITE) == 0 &&
 		 getenv("MBOX_LAZY_WRITES") != NULL);
 
 
@@ -1419,8 +1420,10 @@
 
 	if ((flags & MAILBOX_SYNC_FLAG_FAST) == 0 ||
 	    ibox->sync_last_check + MAILBOX_FULL_SYNC_INTERVAL <= ioloop_time) {
-		if ((flags & MAILBOX_SYNC_FLAG_FULL) != 0)
+		if ((flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0)
 			mbox_sync_flags |= MBOX_SYNC_UNDIRTY;
+		if ((flags & MAILBOX_SYNC_FLAG_FULL_WRITE) != 0)
+			mbox_sync_flags |= MBOX_SYNC_REWRITE;
 		ret = mbox_sync(ibox, mbox_sync_flags);
 	}
 

Index: mbox-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-transaction.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mbox-transaction.c	29 Aug 2004 07:52:03 -0000	1.7
+++ mbox-transaction.c	24 Sep 2004 11:47:30 -0000	1.8
@@ -39,8 +39,10 @@
 
 	if (ret == 0) {
 		enum mbox_sync_flags mbox_sync_flags = MBOX_SYNC_LAST_COMMIT;
-		if ((flags & MAILBOX_SYNC_FLAG_FULL) != 0)
+		if ((flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0)
 			mbox_sync_flags |= MBOX_SYNC_UNDIRTY;
+		if ((flags & MAILBOX_SYNC_FLAG_FULL_WRITE) != 0)
+			mbox_sync_flags |= MBOX_SYNC_REWRITE;
 		if (mbox_modified)
 			mbox_sync_flags |= MBOX_SYNC_HEADER;
 		if (mbox_sync(ibox, mbox_sync_flags) < 0)



More information about the dovecot-cvs mailing list