@ -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 ( )
sta rtingOrR unning := make ( chan bool , 1 ) // gets value once starting or r unning
running := make ( chan bool , 1 ) // gets value once in state ipn.R unning
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 sta rtingOrR unning <- 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
// ' sta rtingOrR unning' 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 ' sta rtingOrR unning' 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 <- sta rtingOrR unning:
case <- running:
return nil
return nil
case <- pumpCtx . Done ( ) :
case <- pumpCtx . Done ( ) :
select {
select {
case <- sta rtingOrR unning:
case <- running:
return nil
return nil
default :
default :
}
}
return pumpCtx . Err ( )
return pumpCtx . Err ( )
case err := <- pumpErr :
case err := <- pumpErr :
select {
select {
case <- sta rtingOrR unning:
case <- running:
return nil
return nil
default :
default :
}
}