Reduce meaningless goroutines

This commit is contained in:
风扇滑翔翼
2025-06-30 18:09:58 +00:00
committed by GitHub
parent 1c87f33e7d
commit a4c5da7888

View File

@@ -133,7 +133,10 @@ func QueryRecord(domain string, server string) ([]byte, error) {
if echConfigCache.expire == nil {
return echConfigCache.update(domain, server)
} else {
go echConfigCache.update(domain, server)
// 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)
}
return *echConfigCache.echConfig.Load(), nil
}
}