mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-19 16:30:07 +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()
|
p.history.Pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
state, ok := p.extra.Load(url)
|
state, _ := p.extra.LoadOrStoreFn(url, func() *internalProxyState {
|
||||||
if !ok {
|
return &internalProxyState{
|
||||||
state = &internalProxyState{
|
|
||||||
history: queue.New[C.DelayHistory](defaultHistoriesNum),
|
history: queue.New[C.DelayHistory](defaultHistoriesNum),
|
||||||
alive: atomic.NewBool(true),
|
alive: atomic.NewBool(true),
|
||||||
}
|
}
|
||||||
p.extra.Store(url, state)
|
})
|
||||||
}
|
|
||||||
|
|
||||||
if !satisfied {
|
if !satisfied {
|
||||||
record.Delay = 0
|
record.Delay = 0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user