]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Rename mail_index.pending_log2_rotate_time to hdr_log2_rotate_time_delayed...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 20 Jan 2021 16:43:27 +0000 (18:43 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 3 May 2021 13:01:05 +0000 (13:01 +0000)
This describes better what it does. Also add some comments explaining
what its purpose is.

src/lib-index/mail-index-private.h
src/lib-index/mail-index-sync.c
src/lib-index/mail-transaction-log.c

index 9c1dac91b2e862642f1332b4d0966166ab2f2081..b9378f9a387e9a4f4fccecf5709bf87df2ecab60 100644 (file)
@@ -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;
index bbef82384de5701fd6b6aa730a55374fe03eb22e..6322ee18690f803bd612ab2388894d463e5e0692 100644 (file)
@@ -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);
index c0a1c41b1696bdb55fd523ffb1214ac7a76d5f5e..e6c0b3a75dad46f67917d537feb98511896f0391 100644 (file)
@@ -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;
        }
 }