diff 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
line wrap: on
line diff
--- a/src/lib-index/mail-index-write.c	Tue Jul 11 15:33:56 2017 +0300
+++ b/src/lib-index/mail-index-write.c	Tue Jul 11 15:35:16 2017 +0300
@@ -140,6 +140,10 @@
 			hdr->log_file_seq = file->hdr.file_seq;
 			hdr->log_file_head_offset =
 				hdr->log_file_tail_offset = file->hdr.hdr_size;
+			/* Assume .log.2 was created successfully. If it
+			   wasn't, it just causes an extra stat() and gets
+			   fixed later on. */
+			hdr->log2_rotate_time = ioloop_time;
 		}
 	}