From d47797088f52ebfb32ee292b8f6563634863b7d0 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sun, 29 Mar 2020 00:48:41 -0500 Subject: [PATCH] fix shutdown deadlock --- src/yggdrasil/core.go | 2 ++ src/yggdrasil/switch.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/yggdrasil/core.go b/src/yggdrasil/core.go index 98a5c6e..dcb5bc7 100644 --- a/src/yggdrasil/core.go +++ b/src/yggdrasil/core.go @@ -195,8 +195,10 @@ func (c *Core) _stop() { c.addPeerTimer.Stop() } c.link.stop() + /* FIXME this deadlocks, need a waitgroup or something to coordinate shutdown for _, peer := range c.GetPeers() { c.DisconnectPeer(peer.Port) } + */ c.log.Infoln("Stopped") } diff --git a/src/yggdrasil/switch.go b/src/yggdrasil/switch.go index 33f2a1b..7ccb6c9 100644 --- a/src/yggdrasil/switch.go +++ b/src/yggdrasil/switch.go @@ -250,7 +250,7 @@ func (t *switchTable) cleanRoot() { t.time = now if t.data.locator.root != t.key { t.data.seq++ - t.updateTable() + defer t.updateTable() t.core.router.reset(nil) } t.data.locator = switchLocator{root: t.key, tstamp: now.Unix()} @@ -524,7 +524,7 @@ func (t *switchTable) unlockedHandleMsg(msg *switchMsg, fromPort switchPort, rep t.core.peers.sendSwitchMsgs(t) } if true || doUpdate { - t.updateTable() + defer t.updateTable() } return }