From: Timo Sirainen Date: Wed, 29 Sep 2010 15:32:47 +0000 (+0100) Subject: lib-index: Don't waste time on every mailbox open checking if .log.2 should be deleted. X-Git-Tag: 2.0.5~32 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=96975ce7b258b4ed09040bd1dc9a453106dee581;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Don't waste time on every mailbox open checking if .log.2 should be deleted. --- diff --git a/src/lib-index/mail-transaction-log-private.h b/src/lib-index/mail-transaction-log-private.h index 26fddcde90..e879c3001a 100644 --- a/src/lib-index/mail-transaction-log-private.h +++ b/src/lib-index/mail-transaction-log-private.h @@ -96,6 +96,7 @@ struct mail_transaction_log { struct dotlock *dotlock; unsigned int nfs_flush:1; + unsigned int log_2_unlink_checked:1; }; void diff --git a/src/lib-index/mail-transaction-log.c b/src/lib-index/mail-transaction-log.c index 72055299dc..b455f52076 100644 --- a/src/lib-index/mail-transaction-log.c +++ b/src/lib-index/mail-transaction-log.c @@ -87,7 +87,6 @@ int mail_transaction_log_open(struct mail_transaction_log *log) return ret; } mail_transaction_log_set_head(log, file); - mail_transaction_log_2_unlink_old(log); return 1; } @@ -410,6 +409,17 @@ int mail_transaction_log_lock_head(struct mail_transaction_log *log) 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.