@marcel91200 / caddy Mirror · read-only / commits / efc0cc5e
Fork 0

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, 05:15 UTC

caddytls: Move initial storage clean op into goroutine

Sometimes this operation can take a while (we observed 7 minutes recently, with a large, globally-distributed storage backend).

Matthew Holt committed Jul 8, 2020 at 10:59 UTC efc0cc5e8557ebc54dd30931a27767139e808c80
1 file changed +4 -4
modules/caddytls/tls.go
+4 -4
@@ -373,9 +373,9 @@ func (t *TLS) AllMatchingCertificates(san string) []certmagic.Certificate {
373 return t.certCache.AllMatchingCertificates(san)
374 }
375
376 -// keepStorageClean immediately cleans up all known storage units
377 -// if it was not recently done, and starts a goroutine that runs
378 -// the operation at every tick from t.storageCleanTicker.
376 +// keepStorageClean starts a goroutine that immediately cleans up all
377 +// known storage units if it was not recently done, and then runs the
378 +// operation at every tick from t.storageCleanTicker.
379 func (t *TLS) keepStorageClean() {
380 t.storageCleanTicker = time.NewTicker(storageCleanInterval)
381 t.storageCleanStop = make(chan struct{})
@@ -385,6 +385,7 @@ func (t *TLS) keepStorageClean() {
385 log.Printf("[PANIC] storage cleaner: %v\n%s", err, debug.Stack())
386 }
387 }()
388 + t.cleanStorageUnits()
389 for {
390 select {
391 case <-t.storageCleanStop:
@@ -394,7 +395,6 @@ func (t *TLS) keepStorageClean() {
395 }
396 }
397 }()
397 - t.cleanStorageUnits()
398 }
399
400 func (t *TLS) cleanStorageUnits() {