]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Don't waste time on every mailbox open checking if .log.2 should be deleted.
authorTimo Sirainen <tss@iki.fi>
Wed, 29 Sep 2010 15:32:47 +0000 (16:32 +0100)
committerTimo Sirainen <tss@iki.fi>
Wed, 29 Sep 2010 15:32:47 +0000 (16:32 +0100)
src/lib-index/mail-transaction-log-private.h
src/lib-index/mail-transaction-log.c

index 26fddcde90f1b2f46fda1cb7410bb70a54abac3c..e879c3001a54632f83bc2d404f72359aa251ffbe 100644 (file)
@@ -96,6 +96,7 @@ struct mail_transaction_log {
        struct dotlock *dotlock;
 
        unsigned int nfs_flush:1;
+       unsigned int log_2_unlink_checked:1;
 };
 
 void
index 72055299dc052c82cd67970aa0ba8cfe45218c80..b455f5207651d0918b522f927102a1416b4f619f 100644 (file)
@@ -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.