router/registry: fix concurrent map iteration and map write (#1762)

This commit is contained in:
ben-toogood
2020-06-30 17:40:38 +01:00
committed by GitHub
parent 355ad2a1af
commit dcf01ebbf0

View File

@@ -551,6 +551,10 @@ func (r *router) Advertise() (<-chan *Advert, error) {
return nil, errors.New("not running")
}
// we're mutating the subscribers so they need to be locked also
r.sub.Lock()
defer r.sub.Unlock()
// already advertising
if r.eventChan != nil {
advertChan := make(chan *Advert, 128)