From 784acba82398e411de2419231362e439f6f471e8 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sat, 29 Jun 2019 12:14:44 -0500 Subject: [PATCH] I think this fixes the concurrent map read/write panic --- src/yggdrasil/conn.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/yggdrasil/conn.go b/src/yggdrasil/conn.go index a4036c7..0357cca 100644 --- a/src/yggdrasil/conn.go +++ b/src/yggdrasil/conn.go @@ -64,9 +64,11 @@ func (c *Conn) String() string { return fmt.Sprintf("conn=%p", c) } -// This should only be called from the router goroutine +// This should never be called from the router goroutine func (c *Conn) search() error { - sinfo, isIn := c.core.searches.searches[*c.nodeID] + var sinfo *searchInfo + var isIn bool + c.core.router.doAdmin(func() { sinfo, isIn = c.core.searches.searches[*c.nodeID] }) if !isIn { done := make(chan struct{}, 1) var sess *sessionInfo @@ -80,8 +82,10 @@ func (c *Conn) search() error { default: } } - sinfo = c.core.searches.newIterSearch(c.nodeID, c.nodeMask, searchCompleted) - sinfo.continueSearch() + c.core.router.doAdmin(func() { + sinfo = c.core.searches.newIterSearch(c.nodeID, c.nodeMask, searchCompleted) + sinfo.continueSearch() + }) <-done c.session = sess if c.session == nil && err == nil {