dovecot: Sync mbox when committing transaction only when saving ...

dovecot at dovecot.org dovecot at dovecot.org
Sun Sep 30 16:57:36 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/fe5c19ffc119
changeset: 6511:fe5c19ffc119
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Sep 30 16:57:32 2007 +0300
description:
Sync mbox when committing transaction only when saving messages to update
last-uid.

diffstat:

3 files changed, 7 insertions(+), 18 deletions(-)
src/lib-storage/index/mbox/mbox-save.c        |    2 +-
src/lib-storage/index/mbox/mbox-storage.h     |    2 +-
src/lib-storage/index/mbox/mbox-transaction.c |   21 +++++----------------

diffs (66 lines):

diff -r d79975141df2 -r fe5c19ffc119 src/lib-storage/index/mbox/mbox-save.c
--- a/src/lib-storage/index/mbox/mbox-save.c	Sun Sep 30 16:45:36 2007 +0300
+++ b/src/lib-storage/index/mbox/mbox-save.c	Sun Sep 30 16:57:32 2007 +0300
@@ -199,7 +199,7 @@ static void mbox_save_init_sync(struct m
 	ctx->first_saved_uid = ctx->next_uid;
 	ctx->uid_validity = hdr->uid_validity;
 	ctx->synced = TRUE;
-	t->mbox_modified = TRUE;
+	t->mails_saved = TRUE;
 
 	mail_index_view_close(&view);
 }
diff -r d79975141df2 -r fe5c19ffc119 src/lib-storage/index/mbox/mbox-storage.h
--- a/src/lib-storage/index/mbox/mbox-storage.h	Sun Sep 30 16:45:36 2007 +0300
+++ b/src/lib-storage/index/mbox/mbox-storage.h	Sun Sep 30 16:57:32 2007 +0300
@@ -56,7 +56,7 @@ struct mbox_transaction_context {
 
 	struct mbox_save_context *save_ctx;
 	unsigned int mbox_lock_id;
-	unsigned int mbox_modified:1;
+	unsigned int mails_saved:1;
 };
 
 extern struct mail_vfuncs mbox_mail_vfuncs;
diff -r d79975141df2 -r fe5c19ffc119 src/lib-storage/index/mbox/mbox-transaction.c
--- a/src/lib-storage/index/mbox/mbox-transaction.c	Sun Sep 30 16:45:36 2007 +0300
+++ b/src/lib-storage/index/mbox/mbox-transaction.c	Sun Sep 30 16:57:32 2007 +0300
@@ -16,14 +16,12 @@ static int mbox_transaction_commit(struc
 	struct mbox_transaction_context *mt = MAIL_STORAGE_CONTEXT(t);
 	struct mbox_mailbox *mbox = (struct mbox_mailbox *)mt->ictx.ibox;
 	unsigned int lock_id = mt->mbox_lock_id;
-	enum mailbox_sync_flags flags = mt->ictx.commit_flags;
-	bool mbox_modified;
-	bool syncing = t->sync_transaction;
+	bool mails_saved;
 	int ret = 0;
 
 	if (mt->save_ctx != NULL)
 		ret = mbox_transaction_save_commit(mt->save_ctx);
-	mbox_modified = mt->mbox_modified;
+	mails_saved = mt->mails_saved;
 
 	if (ret < 0)
 		index_transaction_finish_rollback(&mt->ictx);
@@ -42,18 +40,9 @@ static int mbox_transaction_commit(struc
 		lock_id = 0;
 	}
 
-	if (ret == 0 && !syncing) {
-		enum mbox_sync_flags mbox_sync_flags = MBOX_SYNC_LAST_COMMIT;
-		if ((flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0 &&
-		    !mbox->mbox_very_dirty_syncs)
-			mbox_sync_flags |= MBOX_SYNC_UNDIRTY;
-		if ((flags & MAILBOX_SYNC_FLAG_FULL_WRITE) != 0)
-			mbox_sync_flags |= MBOX_SYNC_REWRITE;
-		if (mbox_modified) {
-			/* after saving mails we want to update the last-uid */
-			mbox_sync_flags |= MBOX_SYNC_HEADER | MBOX_SYNC_REWRITE;
-		}
-		if (mbox_sync(mbox, mbox_sync_flags) < 0)
+	if (ret == 0 && mails_saved) {
+		/* after saving mails we want to update the last-uid */
+		if (mbox_sync(mbox, MBOX_SYNC_HEADER | MBOX_SYNC_REWRITE) < 0)
 			ret = -1;
 	}
 


More information about the dovecot-cvs mailing list