Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 01:30 UTC
caddytls: Mark storage clean timestamp at end of routine (#4401)
See discussion on 42b7134ffa3bf3e9e86514c82407979c2627a5ab
Matt Holt committed
Nov 2, 2021 at 08:27 UTC
24fda7514ddeebf19a1e872343b45ec523eefcba
1 file changed
+8
-8
modules/caddytls/tls.go
+8
-8
@@ -458,20 +458,17 @@ func (t *TLS) cleanStorageUnits() {
458
defer storageCleanMu.Unlock()
459
460
// If storage was cleaned recently, don't do it again for now. Although the ticker
461
- // drops missed ticks for us, config reloads discard the old ticker and replace it
462
- // with a new one, possibly invoking a cleaning to happen again too soon.
463
- // (We divide the interval by 2 because the actual cleaning takes non-zero time,
464
- // and we don't want to skip cleanings if we don't have to; whereas if a cleaning
465
- // took the entire interval, we'd probably want to skip the next one so we aren't
461
+ // calling this function drops missed ticks for us, config reloads discard the old
462
+ // ticker and replace it with a new one, possibly invoking a cleaning to happen again
463
+ // too soon. (We divide the interval by 2 because the actual cleaning takes non-zero
464
+ // time, and we don't want to skip cleanings if we don't have to; whereas if a cleaning
465
+ // took most of the interval, we'd probably want to skip the next one so we aren't
466
// constantly cleaning. This allows cleanings to take up to half the interval's
467
// duration before we decide to skip the next one.)
468
if !storageClean.IsZero() && time.Since(storageClean) < t.storageCleanInterval()/2 {
469
return
470
}
471
472
- // mark when storage cleaning was last initiated
473
- storageClean = time.Now()
474
-
472
options := certmagic.CleanStorageOptions{
473
OCSPStaples: true,
474
ExpiredCerts: true,
@@ -504,6 +501,9 @@ func (t *TLS) cleanStorageUnits() {
501
}
502
}
503
504
+ // remember last time storage was finished cleaning
505
+ storageClean = time.Now()
506
+
507
t.logger.Info("finished cleaning storage units")
508
}
509