]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Rename mail_index.last_read_log_* to main_index_hdr_log_*
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 20 Jan 2021 15:22:20 +0000 (17:22 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 3 May 2021 13:01:05 +0000 (13:01 +0000)
Also update the comment to describe better what the variables do.

src/lib-index/mail-index-map-read.c
src/lib-index/mail-index-private.h
src/lib-index/mail-index-sync.c
src/lib-index/mail-index-write.c

index 5880b80895e0ea556c1f5103b68215b93affdb8b..52d9e2e80727654cab7805e85ad05d74065f48fe 100644 (file)
@@ -395,8 +395,8 @@ mail_index_map_latest_file(struct mail_index *index, const char **reason_r)
        }
        i_assert(new_map->rec_map->records != NULL);
 
-       index->last_read_log_file_seq = new_map->hdr.log_file_seq;
-       index->last_read_log_file_tail_offset =
+       index->main_index_hdr_log_file_seq = new_map->hdr.log_file_seq;
+       index->main_index_hdr_log_file_tail_offset =
                new_map->hdr.log_file_tail_offset;
 
        mail_index_unmap(&index->map);
index 150532a068fc4aaab063007c70a16a6b954a790e..b08db905dccd8a50d0511c96a98ee018200a6950 100644 (file)
@@ -186,11 +186,13 @@ struct mail_index {
        uint32_t indexid;
        unsigned int inconsistency_id;
 
-       /* last_read_log_file_* contains the seq/offsets we last read from
-          the main index file's headers. these are used to figure out when
-          the main index file should be updated. */
-       uint32_t last_read_log_file_seq;
-       uint32_t last_read_log_file_tail_offset;
+       /* These contain the log_file_seq and log_file_tail_offset that exists
+          in dovecot.index file's header. These are used to figure out if it's
+          time to rewrite the dovecot.index file. Note that these aren't
+          available in index->map->hdr, because it gets updated when
+          transaction log file is read. */
+       uint32_t main_index_hdr_log_file_seq;
+       uint32_t main_index_hdr_log_file_tail_offset;
 
        /* log file which last updated index_deleted */
        uint32_t index_delete_changed_file_seq;
index ae43d2e8578bb918875344e8e5cf726874023b3c..f3b9eb3aa82c9be26a855d76a412c31e12627443 100644 (file)
@@ -835,8 +835,8 @@ static bool mail_index_sync_want_index_write(struct mail_index *index, const cha
 {
        uint32_t log_diff;
 
-       if (index->last_read_log_file_seq != 0 &&
-           index->last_read_log_file_seq != index->map->hdr.log_file_seq) {
+       if (index->main_index_hdr_log_file_seq != 0 &&
+           index->main_index_hdr_log_file_seq != index->map->hdr.log_file_seq) {
                /* dovecot.index points to an old .log file. we were supposed
                   to rewrite the dovecot.index when rotating the log, so
                   we shouldn't usually get here. */
@@ -845,12 +845,12 @@ static bool mail_index_sync_want_index_write(struct mail_index *index, const cha
        }
 
        log_diff = index->map->hdr.log_file_tail_offset -
-               index->last_read_log_file_tail_offset;
+               index->main_index_hdr_log_file_tail_offset;
        if (log_diff > index->optimization_set.index.rewrite_max_log_bytes) {
                *reason_r = t_strdup_printf(
                        ".log read %u..%u > rewrite_max_log_bytes %"PRIuUOFF_T,
                        index->map->hdr.log_file_tail_offset,
-                       index->last_read_log_file_tail_offset,
+                       index->main_index_hdr_log_file_tail_offset,
                        index->optimization_set.index.rewrite_max_log_bytes);
                return TRUE;
        }
@@ -859,7 +859,7 @@ static bool mail_index_sync_want_index_write(struct mail_index *index, const cha
                *reason_r = t_strdup_printf(
                        ".log read %u..%u > rewrite_min_log_bytes %"PRIuUOFF_T,
                        index->map->hdr.log_file_tail_offset,
-                       index->last_read_log_file_tail_offset,
+                       index->main_index_hdr_log_file_tail_offset,
                        index->optimization_set.index.rewrite_min_log_bytes);
                return TRUE;
        }
index 5459ebadf074b960aa8a6855e1d95ce84a46bbd2..7684d353a1fc6d4c7fb33f324eb8e68aff0ccbee 100644 (file)
@@ -204,6 +204,6 @@ void mail_index_write(struct mail_index *index, bool want_rotate,
                        index->filepath, hdr->log_file_seq, reason);
        }
 
-       index->last_read_log_file_seq = hdr->log_file_seq;
-       index->last_read_log_file_tail_offset = hdr->log_file_tail_offset;
+       index->main_index_hdr_log_file_seq = hdr->log_file_seq;
+       index->main_index_hdr_log_file_tail_offset = hdr->log_file_tail_offset;
 }