diff options
| author | Irbe Krumina <irbe@tailscale.com> | 2023-07-14 16:27:22 -0700 |
|---|---|---|
| committer | Irbe Krumina <irbe@tailscale.com> | 2023-07-14 21:18:25 -0700 |
| commit | dc057ff8fa779a75a687e772ac23406196eaec9f (patch) | |
| tree | 0356b526e74bc0ed595b6ce44dd7eee5e3e72c84 | |
| parent | c19b5bfbc391637b11c2acb3c725909a0046d849 (diff) | |
| download | tailscale-irbekrm/fix_logout_loop.tar.xz tailscale-irbekrm/fix_logout_loop.zip | |
controlclient: make logout a no-op if already logged outirbekrm/fix_logout_loop
To prevent subsequent cli logouts from erroring in a loop
Updates #3833
Signed-off-by: Irbe Krumina <irbe@tailscale.com>
| -rw-r--r-- | control/controlclient/auto.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/control/controlclient/auto.go b/control/controlclient/auto.go index a27e9e2fa..8e3ee43e2 100644 --- a/control/controlclient/auto.go +++ b/control/controlclient/auto.go @@ -694,9 +694,18 @@ func (c *Auto) StartLogout() { func (c *Auto) Logout(ctx context.Context) error { c.logf("client.Logout()") + c.mu.Lock() + // This happens if a user logs out when tailscale client is already logged + // out either because the user logged out previously or hasn't yet logged + // in. + if !c.loggedIn { + c.logf("client.Logout(): no action taken, client is already logged out.") + c.mu.Unlock() + return nil + } + errc := make(chan error, 1) - c.mu.Lock() c.loginGoal = &LoginGoal{ wantLoggedIn: false, loggedOutResult: errc, |
