control/controlclient: early return and outdent some code

I found this too hard to read before.

This is pulled out of #12033 as it's unrelated cleanup in retrospect.

Updates #12028

Change-Id: I727c47e573217e3d1973c5b66a76748139cf79ee
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2024-05-07 10:55:26 -07:00 committed by Brad Fitzpatrick
parent 471731771c
commit 80df8ffb85

View File

@ -668,12 +668,14 @@ func (c *Auto) UpdateEndpoints(endpoints []tailcfg.Endpoint) {
}
func (c *Auto) Shutdown() {
c.logf("client.Shutdown()")
c.mu.Lock()
closed := c.closed
if c.closed {
c.mu.Unlock()
return
}
c.logf("client.Shutdown ...")
direct := c.direct
if !closed {
c.closed = true
c.observerQueue.Shutdown()
c.cancelAuthCtxLocked()
@ -682,11 +684,8 @@ func (c *Auto) Shutdown() {
w <- false
}
c.unpauseWaiters = nil
}
c.mu.Unlock()
c.logf("client.Shutdown")
if !closed {
c.unregisterHealthWatch()
<-c.authDone
<-c.mapDone
@ -699,7 +698,6 @@ func (c *Auto) Shutdown() {
c.observerQueue.Wait(ctx)
c.logf("Client.Shutdown done.")
}
}
// NodePublicKey returns the node public key currently in use. This is
// used exclusively in tests.