mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 13:05:46 +00:00
ipn/ipnlocal: centralize assignments to cc + ccAuto in new method
cc vs ccAuto is a mess. It needs to go. But this is a baby step towards getting there. Updates #11649 Change-Id: I34f33934844e580bd823a7d8f2b945cf26c87b3b Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
970b1e21d0
commit
68043a17c2
@ -1838,8 +1838,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
|
|||||||
if prevCC != nil {
|
if prevCC != nil {
|
||||||
defer prevCC.Shutdown() // must be called after b.mu is unlocked
|
defer prevCC.Shutdown() // must be called after b.mu is unlocked
|
||||||
}
|
}
|
||||||
b.cc = cc
|
b.setControlClientLocked(cc)
|
||||||
b.ccAuto, _ = cc.(*controlclient.Auto)
|
|
||||||
endpoints := b.endpoints
|
endpoints := b.endpoints
|
||||||
|
|
||||||
if err := b.initTKALocked(); err != nil {
|
if err := b.initTKALocked(); err != nil {
|
||||||
@ -4567,6 +4566,15 @@ func (b *LocalBackend) requestEngineStatusAndWait() {
|
|||||||
b.statusLock.Unlock()
|
b.statusLock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setControlClientLocked sets the control client to cc,
|
||||||
|
// which may be nil.
|
||||||
|
//
|
||||||
|
// b.mu must be held.
|
||||||
|
func (b *LocalBackend) setControlClientLocked(cc controlclient.Client) {
|
||||||
|
b.cc = cc
|
||||||
|
b.ccAuto, _ = cc.(*controlclient.Auto)
|
||||||
|
}
|
||||||
|
|
||||||
// resetControlClientLocked sets b.cc to nil and returns the old value. If the
|
// resetControlClientLocked sets b.cc to nil and returns the old value. If the
|
||||||
// returned value is non-nil, the caller must call Shutdown on it after
|
// returned value is non-nil, the caller must call Shutdown on it after
|
||||||
// releasing b.mu.
|
// releasing b.mu.
|
||||||
@ -4589,8 +4597,7 @@ func (b *LocalBackend) resetControlClientLocked() controlclient.Client {
|
|||||||
b.numClientStatusCalls.Add(1)
|
b.numClientStatusCalls.Add(1)
|
||||||
}
|
}
|
||||||
prev := b.cc
|
prev := b.cc
|
||||||
b.cc = nil
|
b.setControlClientLocked(nil)
|
||||||
b.ccAuto = nil
|
|
||||||
return prev
|
return prev
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user