fix: Run status callbacks async to solve tailnet race (#3866)
This commit is contained in:
1 parent
3ca6f1fcd4
commit
2fa77a9bbd
1 file changed
+7
-5
+7
-5
@@ -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)
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user