mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-20 11:58:39 +00:00
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:
parent
471731771c
commit
80df8ffb85
@ -668,37 +668,35 @@ func (c *Auto) UpdateEndpoints(endpoints []tailcfg.Endpoint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Auto) Shutdown() {
|
func (c *Auto) Shutdown() {
|
||||||
c.logf("client.Shutdown()")
|
|
||||||
|
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
closed := c.closed
|
if c.closed {
|
||||||
direct := c.direct
|
c.mu.Unlock()
|
||||||
if !closed {
|
return
|
||||||
c.closed = true
|
|
||||||
c.observerQueue.Shutdown()
|
|
||||||
c.cancelAuthCtxLocked()
|
|
||||||
c.cancelMapCtxLocked()
|
|
||||||
for _, w := range c.unpauseWaiters {
|
|
||||||
w <- false
|
|
||||||
}
|
|
||||||
c.unpauseWaiters = nil
|
|
||||||
}
|
}
|
||||||
|
c.logf("client.Shutdown ...")
|
||||||
|
|
||||||
|
direct := c.direct
|
||||||
|
c.closed = true
|
||||||
|
c.observerQueue.Shutdown()
|
||||||
|
c.cancelAuthCtxLocked()
|
||||||
|
c.cancelMapCtxLocked()
|
||||||
|
for _, w := range c.unpauseWaiters {
|
||||||
|
w <- false
|
||||||
|
}
|
||||||
|
c.unpauseWaiters = nil
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
|
|
||||||
c.logf("client.Shutdown")
|
c.unregisterHealthWatch()
|
||||||
if !closed {
|
<-c.authDone
|
||||||
c.unregisterHealthWatch()
|
<-c.mapDone
|
||||||
<-c.authDone
|
<-c.updateDone
|
||||||
<-c.mapDone
|
if direct != nil {
|
||||||
<-c.updateDone
|
direct.Close()
|
||||||
if direct != nil {
|
|
||||||
direct.Close()
|
|
||||||
}
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
||||||
defer cancel()
|
|
||||||
c.observerQueue.Wait(ctx)
|
|
||||||
c.logf("Client.Shutdown done.")
|
|
||||||
}
|
}
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
c.observerQueue.Wait(ctx)
|
||||||
|
c.logf("Client.Shutdown done.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodePublicKey returns the node public key currently in use. This is
|
// NodePublicKey returns the node public key currently in use. This is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user