From 75b5f633cd2c877687cb9ec8b091f74d26bf27bf Mon Sep 17 00:00:00 2001 From: Skyxim Date: Fri, 7 Jan 2022 12:58:40 +0800 Subject: [PATCH] [Fixed] Positive health check multithreading is not safe --- adapter/outboundgroup/fallback.go | 5 ++--- adapter/outboundgroup/urltest.go | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/adapter/outboundgroup/fallback.go b/adapter/outboundgroup/fallback.go index 4ecc8d39..5f365ff8 100644 --- a/adapter/outboundgroup/fallback.go +++ b/adapter/outboundgroup/fallback.go @@ -70,11 +70,10 @@ func (f *Fallback) onDialFailed() { f.failedTimes.Store(-1) f.failedTime.Store(-1) } else { - f.failedTimes.Inc() - failedCount := f.failedTimes.Load() + failedCount := f.failedTimes.Inc() log.Warnln("%s failed count: %d", f.Name(), failedCount) if failedCount > 5 { - log.Debugln("%s failed multiple times.", f.Name()) + log.Warnln("because %s failed multiple times, active health check", f.Name()) for _, proxyProvider := range f.providers { go proxyProvider.HealthCheck() } diff --git a/adapter/outboundgroup/urltest.go b/adapter/outboundgroup/urltest.go index ee6fe13a..c0ac5d3c 100644 --- a/adapter/outboundgroup/urltest.go +++ b/adapter/outboundgroup/urltest.go @@ -147,11 +147,10 @@ func (u *URLTest) onDialFailed() { u.failedTimes.Store(-1) u.failedTime.Store(-1) } else { - u.failedTimes.Inc() - failedCount := u.failedTimes.Load() + failedCount := u.failedTimes.Inc() log.Warnln("%s failed count: %d", u.Name(), failedCount) if failedCount > 5 { - log.Debugln("%s failed multiple times.", u.Name()) + log.Warnln("because %s failed multiple times, active health check", u.Name()) for _, proxyProvider := range u.providers { go proxyProvider.HealthCheck() }