From 5f1aea3636003a282467d7fc01afe39dd9f018eb Mon Sep 17 00:00:00 2001 From: Arceliar Date: Tue, 12 Nov 2019 21:01:32 -0600 Subject: [PATCH] fix deadlock when AddPeer fails --- src/yggdrasil/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yggdrasil/api.go b/src/yggdrasil/api.go index 80f669b6..6dd70b8e 100644 --- a/src/yggdrasil/api.go +++ b/src/yggdrasil/api.go @@ -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 }