mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-12-22 16:07:31 +00:00
Merge pull request #606 from Arceliar/bugfix
fix deadlock when AddPeer fails
This commit is contained in:
commit
17a711ab8a
@ -424,6 +424,7 @@ func (c *Core) AddPeer(addr string, sintf string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
c.config.Mutex.Lock()
|
c.config.Mutex.Lock()
|
||||||
|
defer c.config.Mutex.Unlock()
|
||||||
if sintf == "" {
|
if sintf == "" {
|
||||||
for _, peer := range c.config.Current.Peers {
|
for _, peer := range c.config.Current.Peers {
|
||||||
if peer == addr {
|
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.Current.InterfacePeers[sintf] = append(c.config.Current.InterfacePeers[sintf], addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.config.Mutex.Unlock()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user