From: Timo Sirainen Date: Wed, 20 Jan 2021 16:43:27 +0000 (+0200) Subject: lib-index: Rename mail_index.pending_log2_rotate_time to hdr_log2_rotate_time_delayed... X-Git-Tag: 2.3.16~290 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=382fe4cf01e17e6875b0617a7433d2fc8f9e958d;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Rename mail_index.pending_log2_rotate_time to hdr_log2_rotate_time_delayed_update This describes better what it does. Also add some comments explaining what its purpose is. --- diff --git a/src/lib-index/mail-index-private.h b/src/lib-index/mail-index-private.h index 9c1dac91b2..b9378f9a38 100644 --- a/src/lib-index/mail-index-private.h +++ b/src/lib-index/mail-index-private.h @@ -188,7 +188,6 @@ struct mail_index { struct mail_index_settings set; struct mail_index_optimization_settings optimization_set; - uint32_t pending_log2_rotate_time; pool_t extension_pool; ARRAY(struct mail_index_registered_ext) extensions; @@ -221,6 +220,9 @@ struct mail_index { /* syncing will update this if non-NULL */ struct mail_index_transaction_commit_result *sync_commit_result; + /* Delayed log2_rotate_time update to mail_index_header. This is set + and unset within the same sync. */ + uint32_t hdr_log2_rotate_time_delayed_update; pool_t keywords_pool; ARRAY_TYPE(keywords) keywords; diff --git a/src/lib-index/mail-index-sync.c b/src/lib-index/mail-index-sync.c index bbef82384d..6322ee1869 100644 --- a/src/lib-index/mail-index-sync.c +++ b/src/lib-index/mail-index-sync.c @@ -905,13 +905,17 @@ int mail_index_sync_commit(struct mail_index_sync_ctx **_ctx) &next_uid, sizeof(next_uid), FALSE); } } - if (index->pending_log2_rotate_time != 0) { - uint32_t log2_rotate_time = index->pending_log2_rotate_time; + if (index->hdr_log2_rotate_time_delayed_update != 0) { + /* We checked whether .log.2 should be deleted in this same + sync. It resulted in wanting to change the log2_rotate_time + in the header. Do it here as part of the other changes. */ + uint32_t log2_rotate_time = + index->hdr_log2_rotate_time_delayed_update; mail_index_update_header(ctx->ext_trans, offsetof(struct mail_index_header, log2_rotate_time), &log2_rotate_time, sizeof(log2_rotate_time), TRUE); - index->pending_log2_rotate_time = 0; + index->hdr_log2_rotate_time_delayed_update = 0; } ret2 = mail_index_transaction_commit(&ctx->ext_trans); diff --git a/src/lib-index/mail-transaction-log.c b/src/lib-index/mail-transaction-log.c index c0a1c41b16..e6c0b3a75d 100644 --- a/src/lib-index/mail-transaction-log.c +++ b/src/lib-index/mail-transaction-log.c @@ -64,11 +64,16 @@ static void mail_transaction_log_2_unlink_old(struct mail_transaction_log *log) } if (log2_rotate_time != log->index->map->hdr.log2_rotate_time) { - /* Write this as part of the next sync's transaction. We're + /* Either the log2_rotate_time in header was missing, or we + just deleted the .log.2 and need to set it as nonexistent. + Either way we need to update the header. + + Write this as part of the next sync's transaction. We're here because we're already opening a sync lock, so it'll always happen. It's also required especially with mdbox map index, which doesn't like changes done outside syncing. */ - log->index->pending_log2_rotate_time = log2_rotate_time; + log->index->hdr_log2_rotate_time_delayed_update = + log2_rotate_time; } }