[Style] Positive health check

This commit is contained in:
gVisor bot 2022-01-08 09:23:49 +08:00
parent 27f0f65bfb
commit ffe59c5fba
2 changed files with 9 additions and 3 deletions

View file

@ -66,17 +66,20 @@ func (f *Fallback) onDialFailed() {
f.failedTime.Store(now)
f.failedTimes.Store(1)
} else {
if f.failedTime.Load()-time.Now().UnixMilli() > 5*1000 {
if f.failedTime.Load()-time.Now().UnixMilli() > 5*time.Second.Milliseconds() {
f.failedTimes.Store(-1)
f.failedTime.Store(-1)
} else {
failedCount := f.failedTimes.Inc()
log.Warnln("%s failed count: %d", f.Name(), failedCount)
if failedCount > 5 {
if failedCount >= 5 && failedCount < 6 {
log.Warnln("because %s failed multiple times, active health check", f.Name())
for _, proxyProvider := range f.providers {
go proxyProvider.HealthCheck()
}
f.failedTimes.Store(-1)
f.failedTime.Store(-1)
}
}
}

View file

@ -149,11 +149,14 @@ func (u *URLTest) onDialFailed() {
} else {
failedCount := u.failedTimes.Inc()
log.Warnln("%s failed count: %d", u.Name(), failedCount)
if failedCount > 5 {
if failedCount >= 5 && failedCount < 6 {
log.Warnln("because %s failed multiple times, active health check", u.Name())
for _, proxyProvider := range u.providers {
go proxyProvider.HealthCheck()
}
u.failedTimes.Store(-1)
u.failedTime.Store(-1)
}
}
}