# HG changeset patch # User Timo Sirainen # Date 1184449724 -10800 # Node ID 5b4bf289b98d94d33d1f7c99a1610e68f99f164e # Parent 7a632ae07cea73ec14b725cba438b66818980412 If mail_index_ext_set_reset_id() is called, the transaction may go back to unchanged state and we don't want to write it to transaction log then. diff -r 7a632ae07cea -r 5b4bf289b98d src/lib-index/mail-index-transaction-private.h --- a/src/lib-index/mail-index-transaction-private.h Sun Jul 15 00:45:03 2007 +0300 +++ b/src/lib-index/mail-index-transaction-private.h Sun Jul 15 00:48:44 2007 +0300 @@ -73,7 +73,10 @@ unsigned int pre_hdr_changed:1; unsigned int post_hdr_changed:1; unsigned int reset:1; + /* non-extension updates */ unsigned int log_updates:1; + /* extension updates */ + unsigned int log_ext_updates:1; }; extern void (*hook_mail_index_transaction_created) diff -r 7a632ae07cea -r 5b4bf289b98d src/lib-index/mail-index-transaction.c --- a/src/lib-index/mail-index-transaction.c Sun Jul 15 00:45:03 2007 +0300 +++ b/src/lib-index/mail-index-transaction.c Sun Jul 15 00:48:44 2007 +0300 @@ -87,6 +87,7 @@ t->post_hdr_changed = FALSE; t->reset = FALSE; t->log_updates = FALSE; + t->log_ext_updates = FALSE; } static void mail_index_transaction_free(struct mail_index_transaction *t) @@ -830,7 +831,7 @@ (old_record_size == record_size && old_record_align == record_align)); - t->log_updates = TRUE; + t->log_ext_updates = TRUE; if (!array_is_created(&t->ext_resizes)) i_array_init(&t->ext_resizes, ext_id + 2); @@ -847,13 +848,56 @@ { i_assert(reset_id != 0); - t->log_updates = TRUE; - mail_index_ext_set_reset_id(t, ext_id, reset_id); if (!array_is_created(&t->ext_resets)) i_array_init(&t->ext_resets, ext_id + 2); array_idx_set(&t->ext_resets, ext_id, &reset_id); + t->log_ext_updates = TRUE; +} + +static bool +mail_index_transaction_has_ext_changes(struct mail_index_transaction *t) +{ + unsigned int i, count; + + if (array_is_created(&t->ext_rec_updates)) { + const ARRAY_TYPE(seq_array) *array; + + array = array_get(&t->ext_rec_updates, &count); + for (i = 0; i < count; i++) { + if (array_is_created(&array[i])) + return TRUE; + } + } + if (array_is_created(&t->ext_hdr_updates)) { + struct mail_index_transaction_ext_hdr_update *const *hdr; + + hdr = array_get(&t->ext_hdr_updates, &count); + for (i = 0; i < count; i++) { + if (hdr[i] != NULL) + return TRUE; + } + } + if (array_is_created(&t->ext_resets)) { + const uint32_t *ids; + + ids = array_get(&t->ext_resets, &count); + for (i = 0; i < count; i++) { + if (ids[i] != 0) + return TRUE; + } + } + if (array_is_created(&t->ext_resizes)) { + const struct mail_transaction_ext_intro *resizes; + + resizes = array_get(&t->ext_resizes, &count); + for (i = 0; i < count; i++) { + if (resizes[i].name_size > 0) + return TRUE; + } + } + return FALSE; } void mail_index_ext_set_reset_id(struct mail_index_transaction *t, @@ -891,6 +935,8 @@ if (!array_is_created(&t->ext_reset_ids)) i_array_init(&t->ext_reset_ids, ext_id + 2); array_idx_set(&t->ext_reset_ids, ext_id, &reset_id); + + t->log_ext_updates = mail_index_transaction_has_ext_changes(t); } void mail_index_update_header_ext(struct mail_index_transaction *t, @@ -915,7 +961,7 @@ } *pos = hdr; - t->log_updates = TRUE; + t->log_ext_updates = TRUE; } void mail_index_update_ext(struct mail_index_transaction *t, uint32_t seq, @@ -933,7 +979,7 @@ seq <= t->last_new_seq)); i_assert(ext_id < array_count(&index->extensions)); - t->log_updates = TRUE; + t->log_ext_updates = TRUE; if (!array_is_created(&t->ext_resizes)) { intro = NULL; diff -r 7a632ae07cea -r 5b4bf289b98d src/lib-index/mail-transaction-log-append.c --- a/src/lib-index/mail-transaction-log-append.c Sun Jul 15 00:45:03 2007 +0300 +++ b/src/lib-index/mail-transaction-log-append.c Sun Jul 15 00:48:44 2007 +0300 @@ -578,7 +578,7 @@ struct mail_index *index; int ret; - if (!t->log_updates) { + if (!t->log_updates && !t->log_ext_updates) { /* nothing to append */ *log_file_seq_r = 0; *log_file_offset_r = 0;