]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Check .log.2 rotation only when syncing
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 11 Jul 2017 12:33:56 +0000 (15:33 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 12 Jul 2017 11:30:12 +0000 (14:30 +0300)
Instead of also whenever appending transactions to .log file. This
shouldn't change the behavior much, and it's needed for the following
change to work correctly.

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

index 3391c610c3090c88241c8206e134149c1e93a5cb..f86ca20365db37d3910afa9fd4bb87a65549016e 100644 (file)
@@ -468,17 +468,6 @@ int mail_transaction_log_lock_head(struct mail_transaction_log *log,
        const char *reason;
        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.
@@ -535,6 +524,17 @@ int mail_transaction_log_sync_lock(struct mail_transaction_log *log,
 
        i_assert(!log->index->log_sync_locked);
 
+       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);
+       }
+
        if (mail_transaction_log_lock_head(log, lock_reason) < 0)
                return -1;