mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-19 19:38:40 +00:00
cmd/tailscale/cli: make up block until state Running, not just Starting
At "Starting", the DERP connection isn't yet up. After the first netmap and DERP connect, then it transitions into "Running". Fixes #2708 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
fb8b821710
commit
7f29dcaac1
@ -372,8 +372,8 @@ func runUp(ctx context.Context, args []string) error {
|
|||||||
c, bc, pumpCtx, cancel := connect(ctx)
|
c, bc, pumpCtx, cancel := connect(ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
startingOrRunning := make(chan bool, 1) // gets value once starting or running
|
running := make(chan bool, 1) // gets value once in state ipn.Running
|
||||||
gotEngineUpdate := make(chan bool, 1) // gets value upon an engine update
|
gotEngineUpdate := make(chan bool, 1) // gets value upon an engine update
|
||||||
pumpErr := make(chan error, 1)
|
pumpErr := make(chan error, 1)
|
||||||
go func() { pumpErr <- pump(pumpCtx, bc, c) }()
|
go func() { pumpErr <- pump(pumpCtx, bc, c) }()
|
||||||
|
|
||||||
@ -408,14 +408,14 @@ func runUp(ctx context.Context, args []string) error {
|
|||||||
case ipn.NeedsMachineAuth:
|
case ipn.NeedsMachineAuth:
|
||||||
printed = true
|
printed = true
|
||||||
fmt.Fprintf(os.Stderr, "\nTo authorize your machine, visit (as admin):\n\n\t%s\n\n", prefs.AdminPageURL())
|
fmt.Fprintf(os.Stderr, "\nTo authorize your machine, visit (as admin):\n\n\t%s\n\n", prefs.AdminPageURL())
|
||||||
case ipn.Starting, ipn.Running:
|
case ipn.Running:
|
||||||
// Done full authentication process
|
// Done full authentication process
|
||||||
if printed {
|
if printed {
|
||||||
// Only need to print an update if we printed the "please click" message earlier.
|
// Only need to print an update if we printed the "please click" message earlier.
|
||||||
fmt.Fprintf(os.Stderr, "Success.\n")
|
fmt.Fprintf(os.Stderr, "Success.\n")
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case startingOrRunning <- true:
|
case running <- true:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
cancel()
|
cancel()
|
||||||
@ -480,24 +480,24 @@ func runUp(ctx context.Context, args []string) error {
|
|||||||
|
|
||||||
// This whole 'up' mechanism is too complicated and results in
|
// This whole 'up' mechanism is too complicated and results in
|
||||||
// hairy stuff like this select. We're ultimately waiting for
|
// hairy stuff like this select. We're ultimately waiting for
|
||||||
// 'startingOrRunning' to be done, but even in the case where
|
// 'running' to be done, but even in the case where
|
||||||
// it succeeds, other parts may shut down concurrently so we
|
// it succeeds, other parts may shut down concurrently so we
|
||||||
// need to prioritize reads from 'startingOrRunning' if it's
|
// need to prioritize reads from 'running' if it's
|
||||||
// readable; its send does happen before the pump mechanism
|
// readable; its send does happen before the pump mechanism
|
||||||
// shuts down. (Issue 2333)
|
// shuts down. (Issue 2333)
|
||||||
select {
|
select {
|
||||||
case <-startingOrRunning:
|
case <-running:
|
||||||
return nil
|
return nil
|
||||||
case <-pumpCtx.Done():
|
case <-pumpCtx.Done():
|
||||||
select {
|
select {
|
||||||
case <-startingOrRunning:
|
case <-running:
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
return pumpCtx.Err()
|
return pumpCtx.Err()
|
||||||
case err := <-pumpErr:
|
case err := <-pumpErr:
|
||||||
select {
|
select {
|
||||||
case <-startingOrRunning:
|
case <-running:
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user