mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
fix(vpn/tunnel): cancel updater ticks on tunnel stop (#16598)
Closes https://github.com/coder/coder-desktop-macos/issues/51.
This commit is contained in:
@ -71,6 +71,7 @@ func NewTunnel(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
uCtx, uCancel := context.WithCancel(ctx)
|
||||||
t := &Tunnel{
|
t := &Tunnel{
|
||||||
//nolint:govet // safe to copy the locks here because we haven't started the speaker
|
//nolint:govet // safe to copy the locks here because we haven't started the speaker
|
||||||
speaker: *(s),
|
speaker: *(s),
|
||||||
@ -80,7 +81,8 @@ func NewTunnel(
|
|||||||
requestLoopDone: make(chan struct{}),
|
requestLoopDone: make(chan struct{}),
|
||||||
client: client,
|
client: client,
|
||||||
updater: updater{
|
updater: updater{
|
||||||
ctx: ctx,
|
ctx: uCtx,
|
||||||
|
cancel: uCancel,
|
||||||
netLoopDone: make(chan struct{}),
|
netLoopDone: make(chan struct{}),
|
||||||
uSendCh: s.sendCh,
|
uSendCh: s.sendCh,
|
||||||
agents: map[uuid.UUID]tailnet.Agent{},
|
agents: map[uuid.UUID]tailnet.Agent{},
|
||||||
@ -317,6 +319,7 @@ func sinkEntryToPb(e slog.SinkEntry) *Log {
|
|||||||
// updates to the manager.
|
// updates to the manager.
|
||||||
type updater struct {
|
type updater struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
cancel context.CancelFunc
|
||||||
netLoopDone chan struct{}
|
netLoopDone chan struct{}
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
@ -480,6 +483,7 @@ func (u *updater) stop() error {
|
|||||||
}
|
}
|
||||||
err := u.conn.Close()
|
err := u.conn.Close()
|
||||||
u.conn = nil
|
u.conn = nil
|
||||||
|
u.cancel()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user