mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-20 00:50:06 +08:00
chore: improves thread safety in adapter
This commit is contained in:
parent
b5fa3ee99a
commit
d2007fdc22
@ -178,14 +178,12 @@ func (p *Proxy) URLTest(ctx context.Context, url string, expectedStatus utils.In
|
||||
p.history.Pop()
|
||||
}
|
||||
|
||||
state, ok := p.extra.Load(url)
|
||||
if !ok {
|
||||
state = &internalProxyState{
|
||||
state, _ := p.extra.LoadOrStoreFn(url, func() *internalProxyState {
|
||||
return &internalProxyState{
|
||||
history: queue.New[C.DelayHistory](defaultHistoriesNum),
|
||||
alive: atomic.NewBool(true),
|
||||
}
|
||||
p.extra.Store(url, state)
|
||||
}
|
||||
})
|
||||
|
||||
if !satisfied {
|
||||
record.Delay = 0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user