ipnlocal: don't pause the controlclient until we get at least one netmap.

Without this, macOS would fail to display its menu state correctly if you
started it while !WantRunning. It relies on the netmap in order to show
the logged-in username.

Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
apenwarr/statefix
Avery Pennarun 3 years ago
parent 4ef207833b
commit 0181a4d0ac

@ -129,6 +129,7 @@ func (c *Auto) SetPaused(paused bool) {
if paused == c.paused {
return
}
c.logf("setPaused(%v)", paused)
c.paused = paused
if paused {
// Only cancel the map routine. (The auth routine isn't expensive
@ -267,7 +268,7 @@ func (c *Auto) authRoutine() {
if goal != nil {
c.logf("authRoutine: %s; wantLoggedIn=%v", c.state, goal.wantLoggedIn)
} else {
c.logf("authRoutine: %s; goal=nil", c.state)
c.logf("authRoutine: %s; goal=nil paused=%v", c.state, c.paused)
}
c.mu.Unlock()

@ -234,7 +234,7 @@ func (b *LocalBackend) linkChange(major bool, ifst *interfaces.State) {
networkUp := ifst.AnyInterfaceUp()
if b.cc != nil {
go b.cc.SetPaused(b.state == ipn.Stopped || !networkUp)
go b.cc.SetPaused((b.state == ipn.Stopped && b.netMap != nil) || !networkUp)
}
// If the PAC-ness of the network changed, reconfig wireguard+route to
@ -2067,6 +2067,7 @@ func (b *LocalBackend) enterState(newState ipn.State) {
b.state = newState
prefs := b.prefs
cc := b.cc
netMap := b.netMap
networkUp := b.prevIfState.AnyInterfaceUp()
activeLogin := b.activeLogin
authURL := b.authURL
@ -2088,7 +2089,7 @@ func (b *LocalBackend) enterState(newState ipn.State) {
b.send(ipn.Notify{State: &newState})
if cc != nil {
cc.SetPaused(newState == ipn.Stopped || !networkUp)
cc.SetPaused((newState == ipn.Stopped && netMap != nil) || !networkUp)
}
switch newState {

@ -751,7 +751,11 @@ func TestStateMachine(t *testing.T) {
// NOTE: cc.Shutdown() is correct here, since we didn't call
// b.Shutdown() explicitly ourselves.
// BUG: UpdateEndpoints should be called here since we're not WantRunning.
assert.Equal([]string{"Shutdown", "New", "UpdateEndpoints", "Login", "pause"}, cc.getCalls())
// Note: unpause happens because ipn needs to get at least one netmap
// on startup, otherwise UIs can't show the node list, login
// name, etc when in state ipn.Stopped.
// Arguably they shouldn't try. But they currently do.
assert.Equal([]string{"Shutdown", "New", "UpdateEndpoints", "Login", "unpause"}, cc.getCalls())
nn := notifies.drain(2)
assert.Equal([]string{}, cc.getCalls())

Loading…
Cancel
Save