From 8521d66e2c969c9dd876c3efac0b0dca8760776a Mon Sep 17 00:00:00 2001 From: Naman Sood Date: Thu, 14 Jan 2021 17:01:48 -0500 Subject: [PATCH] copy callbacks into slice since maps aren't copied by value Signed-off-by: Naman Sood --- wgengine/userspace.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wgengine/userspace.go b/wgengine/userspace.go index d3ba2cd04..0921346ea 100644 --- a/wgengine/userspace.go +++ b/wgengine/userspace.go @@ -1312,7 +1312,10 @@ func (e *userspaceEngine) SetDERPMap(dm *tailcfg.DERPMap) { func (e *userspaceEngine) SetNetworkMap(nm *controlclient.NetworkMap) { e.magicConn.SetNetworkMap(nm) e.mu.Lock() - callbacks := e.networkMapCallbacks + callbacks := make([]NetworkMapCallback, 0, 4) + for _, fn := range e.networkMapCallbacks { + callbacks = append(callbacks, fn) + } e.mu.Unlock() for _, fn := range callbacks { fn(nm)