summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJames Tucker <james@tailscale.com>2024-08-08 11:02:30 -0700
committerJames Tucker <james@tailscale.com>2024-08-08 11:02:30 -0700
commit0ce86e813a7df752a25b18fa080f386721adf0a8 (patch)
tree4f0cc442e9a81b314a6430f525e9096fc86ac63e
parent1ed958fe231c12890b77025c6b2aa2be0698c7ec (diff)
downloadtailscale-raggi/callmebaby.tar.xz
tailscale-raggi/callmebaby.zip
wgengine/magicsock: fix the freshness of endpoints in callmemayberaggi/callmebaby
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>
-rw-r--r--wgengine/magicsock/magicsock.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go
index 1d0fa58c3..6178bdab2 100644
--- a/wgengine/magicsock/magicsock.go
+++ b/wgengine/magicsock/magicsock.go
@@ -634,16 +634,17 @@ func (c *Conn) setEndpoints(endpoints []tailcfg.Endpoint) (changed bool) {
}
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 {
go fn()
delete(c.onEndpointRefreshed, de)
}
-
- if endpointSetsEqual(endpoints, c.lastEndpoints) {
- return false
- }
- c.lastEndpoints = endpoints
- return true
+ return changed
}
// SetStaticEndpoints sets static endpoints to the provided value and triggers