control/controlclient: update docs for map & auth context

Updates #cleanup

Signed-off-by: James Sanderson <jsanderson@tailscale.com>
zofrex/auto-login-comments
James Sanderson 2 months ago
parent afaa23c3b4
commit a0d0812969

@ -253,7 +253,8 @@ func (c *Auto) updateControl() {
} }
} }
// cancelAuthCtxLocked is like cancelAuthCtx, but assumes the caller holds c.mu. // cancelAuthCtxLocked cancels the [Auto.authRoutine] goroutine's context &
// creates a new one, causing it to restart. Assumes the caller holds c.mu.
func (c *Auto) cancelAuthCtxLocked() { func (c *Auto) cancelAuthCtxLocked() {
if c.authCancel != nil { if c.authCancel != nil {
c.authCancel() c.authCancel()
@ -264,7 +265,9 @@ func (c *Auto) cancelAuthCtxLocked() {
} }
} }
// cancelMapCtxLocked is like cancelMapCtx, but assumes the caller holds c.mu. // cancelMapCtxLocked cancels the context for the [Auto.mapRoutine] and
// [Auto.updateRoutine] goroutines and creates a new one, causing them to
// restart. Assumes the caller holds c.mu.
func (c *Auto) cancelMapCtxLocked() { func (c *Auto) cancelMapCtxLocked() {
if c.mapCancel != nil { if c.mapCancel != nil {
c.mapCancel() c.mapCancel()
@ -275,8 +278,9 @@ func (c *Auto) cancelMapCtxLocked() {
} }
} }
// restartMap cancels the existing mapPoll and liteUpdates, and then starts a // restartMap cancels the the context for the [Auto.mapRoutine] and
// new one. // [Auto.updateRoutine] goroutines, and then creates a new one, causing them to
// restart.
func (c *Auto) restartMap() { func (c *Auto) restartMap() {
c.mu.Lock() c.mu.Lock()
c.cancelMapCtxLocked() c.cancelMapCtxLocked()
@ -702,8 +706,8 @@ func (c *Auto) Login(flags LoginFlags) {
c.loginGoal = &LoginGoal{ c.loginGoal = &LoginGoal{
flags: flags, flags: flags,
} }
c.cancelMapCtxLocked() c.cancelMapCtxLocked() // unblocks [Auto.mapRoutine] & [Auto.updateRoutine]
c.cancelAuthCtxLocked() c.cancelAuthCtxLocked() // unblocks [Auto.authRoutine]
} }
var ErrClientClosed = errors.New("client closed") var ErrClientClosed = errors.New("client closed")

Loading…
Cancel
Save