Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f2bd8fb

Browse files
committed
Fix race condition for the last node
1 parent c883ada commit f2bd8fb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tailnet/conn.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,9 @@ func (c *Conn) SetNodeCallback(callback func(node *Node)) {
265265
c.lastMutex.Lock()
266266
c.lastPreferredDERP = ni.PreferredDERP
267267
c.lastDERPLatency = ni.DERPLatency
268+
node := makeNode()
268269
c.lastMutex.Unlock()
269-
callback(makeNode())
270+
callback(node)
270271
})
271272
c.wireguardEngine.SetStatusCallback(func(s *wgengine.Status, err error) {
272273
if err != nil {
@@ -278,8 +279,9 @@ func (c *Conn) SetNodeCallback(callback func(node *Node)) {
278279
}
279280
c.lastMutex.Lock()
280281
c.lastEndpoints = endpoints
282+
node := makeNode()
281283
c.lastMutex.Unlock()
282-
callback(makeNode())
284+
callback(node)
283285
})
284286
}
285287

0 commit comments

Comments
 (0)