From 2f422434aa6f89d9c4e3437ce50dda78a9e680b5 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 16 Apr 2021 10:27:56 -0700 Subject: [PATCH] cmd/tailscale/cli: wait on the right contexts in up Signed-off-by: Brad Fitzpatrick --- cmd/tailscale/cli/up.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/tailscale/cli/up.go b/cmd/tailscale/cli/up.go index c27988eea..2289bb5e0 100644 --- a/cmd/tailscale/cli/up.go +++ b/cmd/tailscale/cli/up.go @@ -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 // back to the bus that we then wait on. bc.RequestEngineStatus() - <-gotEngineUpdate + select { + case <-gotEngineUpdate: + case <-pumpCtx.Done(): + return pumpCtx.Err() + } // Special case: bare "tailscale up" means to just start // running, if there's ever been a login. @@ -395,13 +399,13 @@ func runUp(ctx context.Context, args []string) error { select { case <-startingOrRunning: return nil - case <-ctx.Done(): + case <-pumpCtx.Done(): select { case <-startingOrRunning: return nil default: } - return ctx.Err() + return pumpCtx.Err() } }