fix: Run status callbacks async to solve tailnet race (#3866)

This commit is contained in:
Kyle Carberry 2022-09-05 10:43:24 -05:00 committed by GitHub
parent 3ca6f1fcd4
commit 2fa77a9bbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -276,11 +276,13 @@ func (c *Conn) SetNodeCallback(callback func(node *Node)) {
for _, addr := range s.LocalAddrs {
endpoints = append(endpoints, addr.Addr.String())
}
c.lastMutex.Lock()
c.lastEndpoints = endpoints
node := makeNode()
c.lastMutex.Unlock()
callback(node)
go func() {
c.lastMutex.Lock()
c.lastEndpoints = endpoints
node := makeNode()
c.lastMutex.Unlock()
callback(node)
}()
})
}