mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
wgengine/magicsock: fix the freshness of endpoints in callmemaybe
Endpoint storage and state updates are all over the place so the full story is hard to track, but explicitly callmemaybe is executed by a callback that is triggered before the write of new endpoints into the storage that CallMeMaybe sends read from. This is now reordered, so that CallMeMaybe should always observe the most recent endpoints. Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:
parent
1ed958fe23
commit
0ce86e813a
@ -634,16 +634,17 @@ func (c *Conn) setEndpoints(endpoints []tailcfg.Endpoint) (changed bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.lastEndpointsTime = time.Now()
|
c.lastEndpointsTime = time.Now()
|
||||||
|
if !endpointSetsEqual(endpoints, c.lastEndpoints) {
|
||||||
|
changed = true
|
||||||
|
}
|
||||||
|
// lastEndpoints must be updated before onEndpointsRefreshed,
|
||||||
|
// as CallMyMaybe sent via this callback must observe the new endpoints.
|
||||||
|
c.lastEndpoints = endpoints
|
||||||
for de, fn := range c.onEndpointRefreshed {
|
for de, fn := range c.onEndpointRefreshed {
|
||||||
go fn()
|
go fn()
|
||||||
delete(c.onEndpointRefreshed, de)
|
delete(c.onEndpointRefreshed, de)
|
||||||
}
|
}
|
||||||
|
return changed
|
||||||
if endpointSetsEqual(endpoints, c.lastEndpoints) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
c.lastEndpoints = endpoints
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetStaticEndpoints sets static endpoints to the provided value and triggers
|
// SetStaticEndpoints sets static endpoints to the provided value and triggers
|
||||||
|
Loading…
Reference in New Issue
Block a user