Mercurial > dovecot > core-2.2
comparison src/lib-index/mail-index-write.c @ 22326:ba1a35c5ead7
lib-index: Track .log.2 rotation time in index header
This avoids unnecessarily stat()ing the file. Also it's a bit better
since it's tracking the actual rotation time, not the mtime of what the
.log file happened to have at the time of rotation.
The initial rotation timestamp is written only to the dovecot.index header
without going through dovecot.index.log. This works, because the
dovecot.index is written practically always after a log rotation. For the
rare cases when it doesn't happen, the dovecot.index.log.2 just gets
deleted later after the next log rotation.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Tue, 11 Jul 2017 15:35:16 +0300 |
parents | 2e2563132d5f |
children | cb108f786fb4 |
comparison
equal
deleted
inserted
replaced
22325:e01bc3015b2f | 22326:ba1a35c5ead7 |
---|---|
138 i_assert(file->hdr.prev_file_seq == hdr->log_file_seq); | 138 i_assert(file->hdr.prev_file_seq == hdr->log_file_seq); |
139 i_assert(file->hdr.prev_file_offset == hdr->log_file_head_offset); | 139 i_assert(file->hdr.prev_file_offset == hdr->log_file_head_offset); |
140 hdr->log_file_seq = file->hdr.file_seq; | 140 hdr->log_file_seq = file->hdr.file_seq; |
141 hdr->log_file_head_offset = | 141 hdr->log_file_head_offset = |
142 hdr->log_file_tail_offset = file->hdr.hdr_size; | 142 hdr->log_file_tail_offset = file->hdr.hdr_size; |
143 /* Assume .log.2 was created successfully. If it | |
144 wasn't, it just causes an extra stat() and gets | |
145 fixed later on. */ | |
146 hdr->log2_rotate_time = ioloop_time; | |
143 } | 147 } |
144 } | 148 } |
145 | 149 |
146 if (!MAIL_INDEX_IS_IN_MEMORY(index)) { | 150 if (!MAIL_INDEX_IS_IN_MEMORY(index)) { |
147 if (mail_index_recreate(index) < 0) { | 151 if (mail_index_recreate(index) < 0) { |