diff --git a/src/yggdrasil/core.go b/src/yggdrasil/core.go index b466e3e8..d48b6479 100644 --- a/src/yggdrasil/core.go +++ b/src/yggdrasil/core.go @@ -112,29 +112,39 @@ func (c *Core) addPeerLoop() { // config.NodeConfig and then signals the various module goroutines to // reconfigure themselves if needed. func (c *Core) UpdateConfig(config *config.NodeConfig) { - c.log.Debugln("Reloading node configuration...") + c.log.Infoln("Reloading node configuration...") c.config.Replace(*config) - errors := 0 // Each reconfigure function should pass any errors to the channel, then close it - components := []func(chan error){ - c.link.reconfigure, - c.peers.reconfigure, - c.router.reconfigure, - c.router.dht.reconfigure, - c.router.searches.reconfigure, - c.router.sessions.reconfigure, - c.switchTable.reconfigure, + components := map[phony.Actor][]func(chan error){ + &c.router: []func(chan error){ + c.router.reconfigure, + c.router.dht.reconfigure, + c.router.searches.reconfigure, + c.router.sessions.reconfigure, + }, + &c.switchTable: []func(chan error){ + c.switchTable.reconfigure, + c.link.reconfigure, + c.peers.reconfigure, + }, } - for _, component := range components { - response := make(chan error) - go component(response) - for err := range response { - c.log.Errorln(err) - errors++ + // TODO: We count errors here but honestly that provides us with absolutely no + // benefit over components reporting errors themselves, so maybe we can use + // actor.Act() here instead and stop counting errors + for actor, functions := range components { + for _, function := range functions { + response := make(chan error) + phony.Block(actor, func() { + function(response) + }) + for err := range response { + c.log.Errorln(err) + errors++ + } } } diff --git a/src/yggdrasil/link.go b/src/yggdrasil/link.go index e65055bc..ee4b9815 100644 --- a/src/yggdrasil/link.go +++ b/src/yggdrasil/link.go @@ -82,7 +82,7 @@ func (l *link) init(c *Core) error { func (l *link) reconfigure(e chan error) { defer close(e) tcpResponse := make(chan error) - go l.tcp.reconfigure(tcpResponse) + l.tcp.reconfigure(tcpResponse) for err := range tcpResponse { e <- err } diff --git a/src/yggdrasil/router.go b/src/yggdrasil/router.go index d93ba433..5f894d9b 100644 --- a/src/yggdrasil/router.go +++ b/src/yggdrasil/router.go @@ -77,13 +77,11 @@ func (r *router) reconfigure(e chan error) { defer close(e) var errs []error // Reconfigure the router - phony.Block(r, func() { - current := r.core.config.GetCurrent() - err := r.nodeinfo.setNodeInfo(current.NodeInfo, current.NodeInfoPrivacy) - if err != nil { - errs = append(errs, err) - } - }) + current := r.core.config.GetCurrent() + err := r.nodeinfo.setNodeInfo(current.NodeInfo, current.NodeInfoPrivacy) + if err != nil { + errs = append(errs, err) + } for _, err := range errs { e <- err } diff --git a/src/yggdrasil/session.go b/src/yggdrasil/session.go index 9abfeca6..f6855b4d 100644 --- a/src/yggdrasil/session.go +++ b/src/yggdrasil/session.go @@ -164,12 +164,10 @@ func (ss *sessions) init(r *router) { func (ss *sessions) reconfigure(e chan error) { defer close(e) responses := make(map[crypto.Handle]chan error) - phony.Block(ss.router, func() { - for index, session := range ss.sinfos { - responses[index] = make(chan error) - go session.reconfigure(responses[index]) - } - }) + for index, session := range ss.sinfos { + responses[index] = make(chan error) + session.reconfigure(responses[index]) + } for _, response := range responses { for err := range response { e <- err