Skip to content

chore: merge codeql checks to run in parallel #5907

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 15 commits into from
Jan 29, 2023
Merged
Prev Previous commit
Next Next commit
fix: close reconnecting pty conn when exiting agent
  • Loading branch information
kylecarbs committed Jan 29, 2023
commit 0ccc7b63ccba6b2bf6c4782acc8e5bdd44869763
13 changes: 11 additions & 2 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,14 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
logger.Debug(ctx, "accept pty failed", slog.Error(err))
return
}
closed := make(chan struct{})
_ = a.trackConnGoroutine(func() {
select {
case <-network.Closed():
case <-closed:
}
_ = conn.Close()
})
// This cannot use a JSON decoder, since that can
// buffer additional data that is required for the PTY.
rawLen := make([]byte, 2)
Expand All @@ -455,9 +463,10 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
if err != nil {
continue
}
go func() {
_ = a.trackConnGoroutine(func() {
defer close(closed)
_ = a.handleReconnectingPTY(ctx, logger, msg, conn)
}()
})
}
}); err != nil {
return nil, err
Expand Down