Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6093:76da3b271bcf HEAD
Keep flag updates separately from transaction.log_updates flag, because the
flag updates array can become empty.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 19 Jul 2007 02:56:40 +0300 |
parents | 1dac64778a3f |
children | b9f7eb84d4be |
files | src/lib-index/mail-index-transaction-private.h src/lib-index/mail-index-transaction.c src/lib-index/mail-transaction-log-append.c |
diffstat | 3 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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;
--- 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 @@ -756,8 +756,6 @@ 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 */ uint32_t seq;
--- 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 @@ 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 @@ 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 @@ *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; }