Fix iterator issue causing 100% CPU load

This commit is contained in:
Moritz Marquardt 2021-11-24 19:08:34 +01:00
parent ce802734d4
commit e5385be6da
No known key found for this signature in database
GPG key ID: D5788327BEE388B6

View file

@ -443,7 +443,8 @@ func setupCertificates() {
// clean up expired certs
now := time.Now()
expiredCertCount := 0
key, resBytes, err := keyDatabase.Items().Next()
keyDatabaseIterator := keyDatabase.Items()
key, resBytes, err := keyDatabaseIterator.Next()
for err == nil {
if !bytes.Equal(key, MainDomainSuffix) {
resGob := bytes.NewBuffer(resBytes)
@ -464,7 +465,7 @@ func setupCertificates() {
}
}
}
key, resBytes, err = keyDatabase.Items().Next()
key, resBytes, err = keyDatabaseIterator.Next()
}
log.Printf("Removed %d expired certificates from the database", expiredCertCount)