Reduce meaningless goroutines

This commit is contained in:
风扇滑翔翼 2025-06-30 18:09:58 +00:00 committed by GitHub
parent 8b8bd3c40d
commit 16450c57b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -133,7 +133,10 @@ func QueryRecord(domain string, server string) ([]byte, error) {
if echConfigCache.expire == nil { if echConfigCache.expire == nil {
return echConfigCache.update(domain, server) return echConfigCache.update(domain, server)
} else { } else {
// If someone already acquired the lock, it means it is updating, do not start another update goroutine
if echConfigCache.updateLock.TryLock() {
go echConfigCache.update(domain, server) go echConfigCache.update(domain, server)
}
return *echConfigCache.echConfig.Load(), nil return *echConfigCache.echConfig.Load(), nil
} }
} }