From: Timo Sirainen Date: Mon, 27 Mar 2017 14:44:45 +0000 (+0300) Subject: lib-index: Code cleanup - expand LOG_WANT_ROTATE() macro X-Git-Tag: 2.3.0.rc1~1828 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c85dd5fbf419770eb0728267df151edcaa3da4b9;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Code cleanup - expand LOG_WANT_ROTATE() macro There was no reason it had to be a macro. Also this fixes off-by-one error when checking for log_rotate_min_size. --- diff --git a/src/lib-index/mail-transaction-log.c b/src/lib-index/mail-transaction-log.c index 39af0a6fbc..61668c8510 100644 --- a/src/lib-index/mail-transaction-log.c +++ b/src/lib-index/mail-transaction-log.c @@ -214,15 +214,21 @@ void mail_transaction_logs_clean(struct mail_transaction_log *log) i_assert(log->head == NULL || log->files != NULL); } -#define LOG_WANT_ROTATE(file) \ - (((file)->sync_offset > (file)->log->index->log_rotate_min_size && \ - (file)->hdr.create_stamp < \ - ioloop_time - (file)->log->index->log_rotate_min_created_ago_secs) || \ - ((file)->sync_offset > (file)->log->index->log_rotate_max_size)) - bool mail_transaction_log_want_rotate(struct mail_transaction_log *log) { - return LOG_WANT_ROTATE(log->head); + struct mail_transaction_log_file *file = log->head; + + if (file->sync_offset > log->index->log_rotate_max_size) { + /* file is too large, definitely rotate */ + return TRUE; + } + if (file->sync_offset < log->index->log_rotate_min_size) { + /* file is still too small */ + return FALSE; + } + /* rotate if the timestamp is old enough */ + return file->hdr.create_stamp < + ioloop_time - log->index->log_rotate_min_created_ago_secs; } int mail_transaction_log_rotate(struct mail_transaction_log *log, bool reset)