5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-12-23 11:05:40 +00:00

Merge pull request #443 from Arceliar/dial

Bugfix in dial code
This commit is contained in:
Arceliar 2019-06-29 12:21:19 -05:00 committed by GitHub
commit 8ecf99d8a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {