From dcf01ebbf033253a690dd960b026cd60664c63ae Mon Sep 17 00:00:00 2001 From: ben-toogood Date: Tue, 30 Jun 2020 17:40:38 +0100 Subject: [PATCH] router/registry: fix concurrent map iteration and map write (#1762) --- router/default.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/router/default.go b/router/default.go index 0b5f93b2..5d20b953 100644 --- a/router/default.go +++ b/router/default.go @@ -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)