Skip to content

Commit 2a248b1

Browse files
fix(vpn/tunnel): cancel updater ticks on tunnel stop (#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

vpn/tunnel.go

Lines changed: 5 additions & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy