Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(vpn/tunnel): cancel updater ticks on tunnel stop #16598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion vpn/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func NewTunnel(
if err != nil {
return nil, err
}
uCtx, uCancel := context.WithCancel(ctx)
t := &Tunnel{
//nolint:govet // safe to copy the locks here because we haven't started the speaker
speaker: *(s),
Expand All @@ -80,7 +81,8 @@ func NewTunnel(
requestLoopDone: make(chan struct{}),
client: client,
updater: updater{
ctx: ctx,
ctx: uCtx,
cancel: uCancel,
netLoopDone: make(chan struct{}),
uSendCh: s.sendCh,
agents: map[uuid.UUID]tailnet.Agent{},
Expand Down Expand Up @@ -317,6 +319,7 @@ func sinkEntryToPb(e slog.SinkEntry) *Log {
// updates to the manager.
type updater struct {
ctx context.Context
cancel context.CancelFunc
netLoopDone chan struct{}

mu sync.Mutex
Expand Down Expand Up @@ -480,6 +483,7 @@ func (u *updater) stop() error {
}
err := u.conn.Close()
u.conn = nil
u.cancel()
return err
}

Expand Down
Loading