mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
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>
This commit is contained in:
parent
2398993804
commit
1fcae42055
@ -72,6 +72,11 @@ func (c *Auto) waitUnpause(routineLogName string) error {
|
|||||||
func (c *Auto) updateRoutine() {
|
func (c *Auto) updateRoutine() {
|
||||||
defer close(c.updateDone)
|
defer close(c.updateDone)
|
||||||
bo := backoff.NewBackoff("updateRoutine", c.logf, 30*time.Second)
|
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 {
|
for {
|
||||||
if err := c.waitUnpause("updateRoutine"); err != nil {
|
if err := c.waitUnpause("updateRoutine"); err != nil {
|
||||||
c.logf("updateRoutine: exiting")
|
c.logf("updateRoutine: exiting")
|
||||||
@ -80,7 +85,7 @@ func (c *Auto) updateRoutine() {
|
|||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
gen := c.lastUpdateGen
|
gen := c.lastUpdateGen
|
||||||
ctx := c.mapCtx
|
ctx := c.mapCtx
|
||||||
needUpdate := gen > 0 && gen != c.lastUpdateGenInformed && c.loggedIn
|
needUpdate := gen > 0 && gen != lastUpdateGenInformed && c.loggedIn
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
|
|
||||||
if needUpdate {
|
if needUpdate {
|
||||||
@ -114,9 +119,7 @@ func (c *Auto) updateRoutine() {
|
|||||||
bo.BackOff(ctx, nil)
|
bo.BackOff(ctx, nil)
|
||||||
c.direct.logf("[v1] successful lite map update in %v", d)
|
c.direct.logf("[v1] successful lite map update in %v", d)
|
||||||
|
|
||||||
c.mu.Lock()
|
lastUpdateGenInformed = gen
|
||||||
c.lastUpdateGenInformed = gen
|
|
||||||
c.mu.Unlock()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,9 +154,6 @@ type Auto struct {
|
|||||||
// lastUpdateGen is the gen of last update we had an update worth sending to
|
// lastUpdateGen is the gen of last update we had an update worth sending to
|
||||||
// the server.
|
// the server.
|
||||||
lastUpdateGen updateGen
|
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
|
paused bool // whether we should stop making HTTP requests
|
||||||
unpauseWaiters []chan struct{}
|
unpauseWaiters []chan struct{}
|
||||||
|
Loading…
Reference in New Issue
Block a user