From b0df9e2f31020373b62d15600410672fe3a2a34c Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 18 Sep 2019 16:15:33 +0100 Subject: [PATCH] Fix race when adding peers --- src/yggdrasil/core.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/yggdrasil/core.go b/src/yggdrasil/core.go index 4cdcd8e4..598d8121 100644 --- a/src/yggdrasil/core.go +++ b/src/yggdrasil/core.go @@ -92,21 +92,21 @@ func (c *Core) _addPeerLoop() { // Add peers from the Peers section for _, peer := range current.Peers { - go func() { - if err := c.AddPeer(peer, ""); err != nil { + go func(peer, intf string) { + if err := c.AddPeer(peer, intf); err != nil { c.log.Errorln("Failed to add peer:", err) } - }() // TODO: this should be acted and not in a goroutine? + }(peer, "") // TODO: this should be acted and not in a goroutine? } // Add peers from the InterfacePeers section for intf, intfpeers := range current.InterfacePeers { for _, peer := range intfpeers { - go func() { + go func(peer, intf string) { if err := c.AddPeer(peer, intf); err != nil { c.log.Errorln("Failed to add peer:", err) } - }() // TODO: this should be acted and not in a goroutine? + }(peer, intf) // TODO: this should be acted and not in a goroutine? } }