5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-10 05:10:26 +00:00

Fix race when adding peers

This commit is contained in:
Neil Alexander 2019-09-18 16:15:33 +01:00
parent c78a4cb28f
commit b0df9e2f31
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -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?
}
}