]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Don't rotate transaction log too often
authorTimo Sirainen <tss@iki.fi>
Mon, 3 May 2004 22:19:39 +0000 (01:19 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 3 May 2004 22:19:39 +0000 (01:19 +0300)
--HG--
branch : HEAD

src/lib-index/mail-transaction-log-private.h
src/lib-index/mail-transaction-log.c
src/lib-index/mail-transaction-log.h

index d749300bee128655e7fe3bdb09a31177e1eb2caa..4ce5c01988d32522da6acef0fc7dcac046dee394 100644 (file)
@@ -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;
index b6518ee32b30a4619beb997c06dc75596ab91d6e..8f8f1a7bb2aa5a10ab5995a2eacfbf739e3aca99 100644 (file)
@@ -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) {
index cceb93b1cd33cb6abecb0ec624a9271274c8307c..c6dea12306f8b41599449a13c108951ab1e233f5 100644 (file)
@@ -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;