cmd/tailscale/cli: wait on the right contexts in up

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2021-04-16 10:27:56 -07:00
parent 6da812b4cf
commit 2f422434aa

View File

@ -352,7 +352,11 @@ func runUp(ctx context.Context, args []string) error {
// an update upon its transition to running. Do so by causing some traffic // an update upon its transition to running. Do so by causing some traffic
// back to the bus that we then wait on. // back to the bus that we then wait on.
bc.RequestEngineStatus() bc.RequestEngineStatus()
<-gotEngineUpdate select {
case <-gotEngineUpdate:
case <-pumpCtx.Done():
return pumpCtx.Err()
}
// Special case: bare "tailscale up" means to just start // Special case: bare "tailscale up" means to just start
// running, if there's ever been a login. // running, if there's ever been a login.
@ -395,13 +399,13 @@ func runUp(ctx context.Context, args []string) error {
select { select {
case <-startingOrRunning: case <-startingOrRunning:
return nil return nil
case <-ctx.Done(): case <-pumpCtx.Done():
select { select {
case <-startingOrRunning: case <-startingOrRunning:
return nil return nil
default: default:
} }
return ctx.Err() return pumpCtx.Err()
} }
} }