From: Timo Sirainen Date: Mon, 3 May 2004 22:19:39 +0000 (+0300) Subject: Don't rotate transaction log too often X-Git-Tag: 1.1.alpha1~4130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55a210942dc7da58b2fd0b11bed8da6b030af5c1;p=thirdparty%2Fdovecot%2Fcore.git Don't rotate transaction log too often --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-transaction-log-private.h b/src/lib-index/mail-transaction-log-private.h index d749300bee..4ce5c01988 100644 --- a/src/lib-index/mail-transaction-log-private.h +++ b/src/lib-index/mail-transaction-log-private.h @@ -16,6 +16,7 @@ struct mail_transaction_log_file { ino_t st_ino; dev_t st_dev; + time_t last_mtime; buffer_t *buffer; uoff_t buffer_offset; diff --git a/src/lib-index/mail-transaction-log.c b/src/lib-index/mail-transaction-log.c index b6518ee32b..8f8f1a7bb2 100644 --- a/src/lib-index/mail-transaction-log.c +++ b/src/lib-index/mail-transaction-log.c @@ -1,6 +1,7 @@ /* Copyright (C) 2003-2004 Timo Sirainen */ #include "lib.h" +#include "ioloop.h" #include "buffer.h" #include "file-lock.h" #include "file-dotlock.h" @@ -419,6 +420,7 @@ mail_transaction_log_file_fd_open(struct mail_transaction_log *log, file->lock_type = F_UNLCK; file->st_dev = st.st_dev; file->st_ino = st.st_ino; + file->last_mtime = st.st_mtime; ret = mail_transaction_log_file_read_hdr(file, &st); if (ret == 0) { @@ -439,6 +441,7 @@ mail_transaction_log_file_fd_open(struct mail_transaction_log *log, file->st_dev = st.st_dev; file->st_ino = st.st_ino; + file->last_mtime = st.st_mtime; memset(&file->hdr, 0, sizeof(file->hdr)); ret = mail_transaction_log_file_read_hdr(file, &st); @@ -1098,7 +1101,9 @@ int mail_transaction_log_append(struct mail_index_transaction *t, } if (log->head->hdr.file_seq == index->hdr->log_file_seq && - log->head->hdr.used_size > MAIL_TRANSACTION_LOG_ROTATE_SIZE) { + log->head->hdr.used_size > MAIL_TRANSACTION_LOG_ROTATE_SIZE && + log->head->last_mtime < + ioloop_time - MAIL_TRANSACTION_LOG_ROTATE_MIN_TIME) { /* everything synced in index, we can rotate. */ if (mail_transaction_log_rotate(log) < 0) { if (!log->index->log_locked) { diff --git a/src/lib-index/mail-transaction-log.h b/src/lib-index/mail-transaction-log.h index cceb93b1cd..c6dea12306 100644 --- a/src/lib-index/mail-transaction-log.h +++ b/src/lib-index/mail-transaction-log.h @@ -3,6 +3,7 @@ #define MAIL_TRANSACTION_LOG_PREFIX ".log" #define MAIL_TRANSACTION_LOG_ROTATE_SIZE (1024*128) +#define MAIL_TRANSACTION_LOG_ROTATE_MIN_TIME (60*5) struct mail_transaction_log_header { uint32_t indexid;