Skip to content

Commit 2a248b1

Browse files
fix(vpn/tunnel): cancel updater ticks on tunnel stop (coder#16598)
Closes coder/coder-desktop-macos#51.
1 parent 06b2186 commit 2a248b1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: vpn/tunnel.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func NewTunnel(
7171
if err != nil {
7272
return nil, err
7373
}
74+
uCtx, uCancel := context.WithCancel(ctx)
7475
t := &Tunnel{
7576
//nolint:govet // safe to copy the locks here because we haven't started the speaker
7677
speaker: *(s),
@@ -80,7 +81,8 @@ func NewTunnel(
8081
requestLoopDone: make(chan struct{}),
8182
client: client,
8283
updater: updater{
83-
ctx: ctx,
84+
ctx: uCtx,
85+
cancel: uCancel,
8486
netLoopDone: make(chan struct{}),
8587
uSendCh: s.sendCh,
8688
agents: map[uuid.UUID]tailnet.Agent{},
@@ -317,6 +319,7 @@ func sinkEntryToPb(e slog.SinkEntry) *Log {
317319
// updates to the manager.
318320
type updater struct {
319321
ctx context.Context
322+
cancel context.CancelFunc
320323
netLoopDone chan struct{}
321324

322325
mu sync.Mutex
@@ -480,6 +483,7 @@ func (u *updater) stop() error {
480483
}
481484
err := u.conn.Close()
482485
u.conn = nil
486+
u.cancel()
483487
return err
484488
}
485489

0 commit comments

Comments
 (0)