Skip to content

Commit 53f8adb

Browse files
committed
fix: Run status callbacks async to solve tailnet race
1 parent 1a5d3ea commit 53f8adb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tailnet/conn.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,13 @@ func (c *Conn) SetNodeCallback(callback func(node *Node)) {
276276
for _, addr := range s.LocalAddrs {
277277
endpoints = append(endpoints, addr.Addr.String())
278278
}
279-
c.lastMutex.Lock()
280-
c.lastEndpoints = endpoints
281-
node := makeNode()
282-
c.lastMutex.Unlock()
283-
callback(node)
279+
go func() {
280+
c.lastMutex.Lock()
281+
c.lastEndpoints = endpoints
282+
node := makeNode()
283+
c.lastMutex.Unlock()
284+
callback(node)
285+
}()
284286
})
285287
}
286288

0 commit comments

Comments
 (0)