From 24fda7514ddeebf19a1e872343b45ec523eefcba Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Tue, 2 Nov 2021 08:27:25 -0600 Subject: caddytls: Mark storage clean timestamp at end of routine (#4401) See discussion on 42b7134ffa3bf3e9e86514c82407979c2627a5ab --- modules/caddytls/tls.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'modules/caddytls') diff --git a/modules/caddytls/tls.go b/modules/caddytls/tls.go index 778ae02..31c559c 100644 --- a/modules/caddytls/tls.go +++ b/modules/caddytls/tls.go @@ -458,20 +458,17 @@ func (t *TLS) cleanStorageUnits() { defer storageCleanMu.Unlock() // If storage was cleaned recently, don't do it again for now. Although the ticker - // drops missed ticks for us, config reloads discard the old ticker and replace it - // with a new one, possibly invoking a cleaning to happen again too soon. - // (We divide the interval by 2 because the actual cleaning takes non-zero time, - // and we don't want to skip cleanings if we don't have to; whereas if a cleaning - // took the entire interval, we'd probably want to skip the next one so we aren't + // calling this function drops missed ticks for us, config reloads discard the old + // ticker and replace it with a new one, possibly invoking a cleaning to happen again + // too soon. (We divide the interval by 2 because the actual cleaning takes non-zero + // time, and we don't want to skip cleanings if we don't have to; whereas if a cleaning + // took most of the interval, we'd probably want to skip the next one so we aren't // constantly cleaning. This allows cleanings to take up to half the interval's // duration before we decide to skip the next one.) if !storageClean.IsZero() && time.Since(storageClean) < t.storageCleanInterval()/2 { return } - // mark when storage cleaning was last initiated - storageClean = time.Now() - options := certmagic.CleanStorageOptions{ OCSPStaples: true, ExpiredCerts: true, @@ -504,6 +501,9 @@ func (t *TLS) cleanStorageUnits() { } } + // remember last time storage was finished cleaning + storageClean = time.Now() + t.logger.Info("finished cleaning storage units") } -- cgit v1.2.3