summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2023-08-13 08:31:15 -0700
committerBrad Fitzpatrick <brad@danga.com>2023-08-13 10:39:17 -0700
commit1fcae420552d0a2d6a2fbb2d40fb62a126451fc2 (patch)
treeb8fa77af69580816ea7935881717417d35d396bc
parent2398993804125389b757047c3833cfa21e611024 (diff)
downloadtailscale-1fcae420552d0a2d6a2fbb2d40fb62a126451fc2.tar.xz
tailscale-1fcae420552d0a2d6a2fbb2d40fb62a126451fc2.zip
control/controlclient: move lastUpdateGenInformed to tighter scope
No need to have it on Auto or be behind a mutex; it's only read/written from a single goroutine. Move it there. Updates tailscale/corp#5761 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
-rw-r--r--control/controlclient/auto.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/control/controlclient/auto.go b/control/controlclient/auto.go
index 3172ae352..5ada58552 100644
--- a/control/controlclient/auto.go
+++ b/control/controlclient/auto.go
@@ -72,6 +72,11 @@ func (c *Auto) waitUnpause(routineLogName string) error {
func (c *Auto) updateRoutine() {
defer close(c.updateDone)
bo := backoff.NewBackoff("updateRoutine", c.logf, 30*time.Second)
+
+ // lastUpdateGenInformed is the value of lastUpdateAt that we've successfully
+ // informed the server of.
+ var lastUpdateGenInformed updateGen
+
for {
if err := c.waitUnpause("updateRoutine"); err != nil {
c.logf("updateRoutine: exiting")
@@ -80,7 +85,7 @@ func (c *Auto) updateRoutine() {
c.mu.Lock()
gen := c.lastUpdateGen
ctx := c.mapCtx
- needUpdate := gen > 0 && gen != c.lastUpdateGenInformed && c.loggedIn
+ needUpdate := gen > 0 && gen != lastUpdateGenInformed && c.loggedIn
c.mu.Unlock()
if needUpdate {
@@ -114,9 +119,7 @@ func (c *Auto) updateRoutine() {
bo.BackOff(ctx, nil)
c.direct.logf("[v1] successful lite map update in %v", d)
- c.mu.Lock()
- c.lastUpdateGenInformed = gen
- c.mu.Unlock()
+ lastUpdateGenInformed = gen
}
}
@@ -151,9 +154,6 @@ type Auto struct {
// lastUpdateGen is the gen of last update we had an update worth sending to
// the server.
lastUpdateGen updateGen
- // lastUpdateGenInformed is the value of lastUpdateAt that we've successfully
- // informed the server of.
- lastUpdateGenInformed updateGen
paused bool // whether we should stop making HTTP requests
unpauseWaiters []chan struct{}