Mercurial > dovecot > core-2.2
changeset 12199:e670e8a97a8f
lib-index: Don't waste time on every mailbox open checking if .log.2 should be deleted.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 29 Sep 2010 16:32:47 +0100 |
parents | c992b1942e08 |
children | 5db6b49f31c4 |
files | src/lib-index/mail-transaction-log-private.h src/lib-index/mail-transaction-log.c |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-transaction-log-private.h Wed Sep 29 15:46:32 2010 +0100 +++ b/src/lib-index/mail-transaction-log-private.h Wed Sep 29 16:32:47 2010 +0100 @@ -96,6 +96,7 @@ struct dotlock *dotlock; unsigned int nfs_flush:1; + unsigned int log_2_unlink_checked:1; }; void
--- a/src/lib-index/mail-transaction-log.c Wed Sep 29 15:46:32 2010 +0100 +++ b/src/lib-index/mail-transaction-log.c Wed Sep 29 16:32:47 2010 +0100 @@ -87,7 +87,6 @@ return ret; } mail_transaction_log_set_head(log, file); - mail_transaction_log_2_unlink_old(log); return 1; } @@ -410,6 +409,17 @@ struct mail_transaction_log_file *file; int ret = 0; + if (!log->log_2_unlink_checked) { + /* we need to check once in a while if .log.2 should be deleted + to avoid wasting space on such old files. but we also don't + want to waste time on checking it when the same mailbox + gets opened over and over again rapidly (e.g. pop3). so + do this only when there have actually been some changes + to mailbox (i.e. when it's being locked here) */ + log->log_2_unlink_checked = TRUE; + mail_transaction_log_2_unlink_old(log); + } + /* we want to get the head file locked. this is a bit racy, since by the time we have it locked a new log file may have been created.