dovecot: Keep flag updates separately from transaction.log_updat...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 19 02:56:48 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/76da3b271bcf
changeset: 6093:76da3b271bcf
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jul 19 02:56:40 2007 +0300
description:
Keep flag updates separately from transaction.log_updates flag, because the
flag updates array can become empty.

diffstat:

3 files changed, 9 insertions(+), 5 deletions(-)
src/lib-index/mail-index-transaction-private.h |    4 +++-
src/lib-index/mail-index-transaction.c         |    2 --
src/lib-index/mail-transaction-log-append.c    |    8 ++++++--

diffs (58 lines):

diff -r 1dac64778a3f -r 76da3b271bcf src/lib-index/mail-index-transaction-private.h
--- a/src/lib-index/mail-index-transaction-private.h	Thu Jul 19 02:52:21 2007 +0300
+++ b/src/lib-index/mail-index-transaction-private.h	Thu Jul 19 02:56:40 2007 +0300
@@ -72,7 +72,9 @@ struct mail_index_transaction {
 	unsigned int pre_hdr_changed:1;
 	unsigned int post_hdr_changed:1;
 	unsigned int reset:1;
-	/* non-extension updates */
+	/* non-extension updates. flag updates don't change this because
+	   they may be added and removed, so be sure to check that the updates
+	   array is non-empty also. */
 	unsigned int log_updates:1;
 	/* extension updates */
 	unsigned int log_ext_updates:1;
diff -r 1dac64778a3f -r 76da3b271bcf src/lib-index/mail-index-transaction.c
--- a/src/lib-index/mail-index-transaction.c	Thu Jul 19 02:52:21 2007 +0300
+++ b/src/lib-index/mail-index-transaction.c	Thu Jul 19 02:56:40 2007 +0300
@@ -755,8 +755,6 @@ void mail_index_update_flags_range(struc
 	struct mail_index_record *rec;
 	struct mail_transaction_flag_update u, *last_update;
 	unsigned int count;
-
-	t->log_updates = TRUE;
 
 	if (seq2 >= t->first_new_seq) {
 		/* updates for appended messages, modify them directly */
diff -r 1dac64778a3f -r 76da3b271bcf src/lib-index/mail-transaction-log-append.c
--- a/src/lib-index/mail-transaction-log-append.c	Thu Jul 19 02:52:21 2007 +0300
+++ b/src/lib-index/mail-transaction-log-append.c	Thu Jul 19 02:56:40 2007 +0300
@@ -448,6 +448,10 @@ static void log_append_sync_offset_if_ne
 	log_append_buffer(ctx, buf, NULL, MAIL_TRANSACTION_HEADER_UPDATE);
 }
 
+#define TRANSACTION_HAS_CHANGES(t) \
+	((t)->log_updates || (t)->log_ext_updates || \
+	 (array_is_created(&(t)->updates) && array_count(&(t)->updates) > 0))
+
 static int
 mail_transaction_log_append_locked(struct mail_index_transaction *t,
 				   uint32_t *log_file_seq_r,
@@ -470,7 +474,7 @@ mail_transaction_log_append_locked(struc
 		if (mail_transaction_log_rotate(log, TRUE) < 0)
 			return -1;
 
-		if (!t->log_updates && !t->log_ext_updates) {
+		if (!TRANSACTION_HAS_CHANGES(t)) {
 			/* we only wanted to reset */
 			return 0;
 		}
@@ -581,7 +585,7 @@ int mail_transaction_log_append(struct m
 	*log_file_seq_r = 0;
 	*log_file_offset_r = 0;
 
-	if (!t->log_updates && !t->log_ext_updates && !t->reset) {
+	if (!TRANSACTION_HAS_CHANGES(t) && !t->reset) {
 		/* nothing to append */
 		return 0;
 	}


More information about the dovecot-cvs mailing list