Skip to content

Commit

Permalink
fix a shared fastSingle.Do() may cause providers untouched
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Jan 20, 2025
1 parent c243cc3 commit 62b45f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion adapter/outboundgroup/fallback.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ func (f *Fallback) Unwrap(metadata *C.Metadata, touch bool) C.Proxy {
}

func (f *Fallback) proxies(touch bool) []C.Proxy {
elm, _, _ := f.single.Do(func() ([]C.Proxy, error) {
elm, _, shared := f.single.Do(func() ([]C.Proxy, error) {
return getProvidersProxies(f.providers, touch, f.filter), nil
})
if shared && touch { // a shared fastSingle.Do() may cause providers untouched, so we touch them again
touchProviders(f.providers)
}

return elm
}
Expand Down
5 changes: 4 additions & 1 deletion adapter/outboundgroup/loadbalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,12 @@ func (lb *LoadBalance) Unwrap(metadata *C.Metadata, touch bool) C.Proxy {
}

func (lb *LoadBalance) proxies(touch bool) []C.Proxy {
elm, _, _ := lb.single.Do(func() ([]C.Proxy, error) {
elm, _, shared := lb.single.Do(func() ([]C.Proxy, error) {
return getProvidersProxies(lb.providers, touch, lb.filter), nil
})
if shared && touch { // a shared fastSingle.Do() may cause providers untouched, so we touch them again
touchProviders(lb.providers)
}

return elm
}
Expand Down

0 comments on commit 62b45f7

Please sign in to comment.