mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-15 05:31:18 +08:00
Chore: health checks return immediately if completed (#1097)
This commit is contained in:
parent
994cbff215
commit
0d33dc3eb9
@ -2,6 +2,7 @@ package provider
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
@ -59,11 +60,18 @@ func (hc *HealthCheck) touch() {
|
||||
|
||||
func (hc *HealthCheck) check() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), defaultURLTestTimeout)
|
||||
wg := &sync.WaitGroup{}
|
||||
|
||||
for _, proxy := range hc.proxies {
|
||||
go proxy.URLTest(ctx, hc.url)
|
||||
wg.Add(1)
|
||||
|
||||
go func(p C.Proxy) {
|
||||
p.URLTest(ctx, hc.url)
|
||||
wg.Done()
|
||||
}(proxy)
|
||||
}
|
||||
|
||||
<-ctx.Done()
|
||||
wg.Wait()
|
||||
cancel()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user