4
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2025-06-15 05:06:06 +00:00

Merge pull request #606 from Arceliar/bugfix

fix deadlock when AddPeer fails
This commit is contained in:
Arceliar
2019-11-12 21:08:36 -06:00
committed by GitHub

View File

@ -424,6 +424,7 @@ func (c *Core) AddPeer(addr string, sintf string) error {
return err
}
c.config.Mutex.Lock()
defer c.config.Mutex.Unlock()
if sintf == "" {
for _, peer := range c.config.Current.Peers {
if peer == addr {
@ -445,7 +446,6 @@ func (c *Core) AddPeer(addr string, sintf string) error {
c.config.Current.InterfacePeers[sintf] = append(c.config.Current.InterfacePeers[sintf], addr)
}
}
c.config.Mutex.Unlock()
return nil
}