lib/netutil: parallelize background pings for remote addresses

This should improve the time needed for determining unavailale remote addresses
across big numer of ConnPool's.

This is a follow-up for a1629bd3be

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/711
This commit is contained in:
Aliaksandr Valialkin 2022-06-21 13:30:58 +03:00
parent 24097f2417
commit 288d13af8d
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -222,8 +222,14 @@ var connPools []*ConnPool
func forEachConnPool(f func(cp *ConnPool)) { func forEachConnPool(f func(cp *ConnPool)) {
connPoolsMu.Lock() connPoolsMu.Lock()
var wg sync.WaitGroup
for _, cp := range connPools { for _, cp := range connPools {
f(cp) wg.Add(1)
go func(cp *ConnPool) {
defer wg.Done()
f(cp)
}(cp)
} }
wg.Wait()
connPoolsMu.Unlock() connPoolsMu.Unlock()
} }