mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-23 18:15:24 +00:00
Fix race when adding peers
This commit is contained in:
parent
c78a4cb28f
commit
b0df9e2f31
@ -92,21 +92,21 @@ func (c *Core) _addPeerLoop() {
|
|||||||
|
|
||||||
// Add peers from the Peers section
|
// Add peers from the Peers section
|
||||||
for _, peer := range current.Peers {
|
for _, peer := range current.Peers {
|
||||||
go func() {
|
go func(peer, intf string) {
|
||||||
if err := c.AddPeer(peer, ""); err != nil {
|
if err := c.AddPeer(peer, intf); err != nil {
|
||||||
c.log.Errorln("Failed to add peer:", err)
|
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
|
// Add peers from the InterfacePeers section
|
||||||
for intf, intfpeers := range current.InterfacePeers {
|
for intf, intfpeers := range current.InterfacePeers {
|
||||||
for _, peer := range intfpeers {
|
for _, peer := range intfpeers {
|
||||||
go func() {
|
go func(peer, intf string) {
|
||||||
if err := c.AddPeer(peer, intf); err != nil {
|
if err := c.AddPeer(peer, intf); err != nil {
|
||||||
c.log.Errorln("Failed to add peer:", err)
|
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?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user