From 2a24effac06e1a9a1d2f9d85db4c0f6049cd8e59 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Mon, 31 Oct 2022 16:58:29 +0800 Subject: [PATCH] chore: better UrlTest's torch --- adapter/outboundgroup/urltest.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adapter/outboundgroup/urltest.go b/adapter/outboundgroup/urltest.go index a0fbe6d1..1e69652c 100644 --- a/adapter/outboundgroup/urltest.go +++ b/adapter/outboundgroup/urltest.go @@ -61,10 +61,7 @@ func (u *URLTest) Unwrap(metadata *C.Metadata, touch bool) C.Proxy { } func (u *URLTest) fast(touch bool) C.Proxy { - if touch { - u.Touch() - } - elm, _, _ := u.fastSingle.Do(func() (C.Proxy, error) { + elm, _, shared := u.fastSingle.Do(func() (C.Proxy, error) { proxies := u.GetProxies(touch) fast := proxies[0] min := fast.LastDelay() @@ -93,6 +90,9 @@ func (u *URLTest) fast(touch bool) C.Proxy { return u.fastNode, nil }) + if shared && touch { // a shared fastSingle.Do() may cause providers untouched, so we touch them again + u.Touch() + } return elm }