remove relay from pool once it's closed or disconnected.
This commit is contained in:
@@ -164,6 +164,12 @@ func (pool *Pool) EnsureRelay(url string) (*Relay, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pool.Relays.Store(nm, relay)
|
pool.Relays.Store(nm, relay)
|
||||||
|
go func(r *Relay, relayURL string) {
|
||||||
|
<-r.Context().Done()
|
||||||
|
if current, ok := pool.Relays.Load(relayURL); ok && current == r {
|
||||||
|
pool.Relays.Delete(relayURL)
|
||||||
|
}
|
||||||
|
}(relay, nm)
|
||||||
return relay, nil
|
return relay, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user