dovecot-2.0: lib-index: Don't waste time on every mailbox open c...

dovecot at dovecot.org dovecot at dovecot.org
Wed Sep 29 18:35:01 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/e670e8a97a8f
changeset: 12199:e670e8a97a8f
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Sep 29 16:32:47 2010 +0100
description:
lib-index: Don't waste time on every mailbox open checking if .log.2 should be deleted.

diffstat:

 src/lib-index/mail-transaction-log-private.h |   1 +
 src/lib-index/mail-transaction-log.c         |  12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletions(-)

diffs (40 lines):

diff -r c992b1942e08 -r e670e8a97a8f src/lib-index/mail-transaction-log-private.h
--- 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
diff -r c992b1942e08 -r e670e8a97a8f src/lib-index/mail-transaction-log.c
--- 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.


More information about the dovecot-cvs mailing list