Skip to content

Commit f662264

Browse files
committed
refactor(ssh): use context control on keep alive between agent and client
1 parent 96473c6 commit f662264

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

ssh/server/channels/session.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func DefaultSessionHandler() gliderssh.ChannelHandler {
179179
return
180180
}
181181

182-
if err := sess.KeepAlive(); err != nil {
182+
if err := sess.KeepAlive(ctx); err != nil {
183183
logger.WithError(err).Error("failed to send the API request to inform that the session is open")
184184

185185
return

ssh/session/session.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,8 @@ func Event[D any](sess *Session, t string, data []byte, seat int) {
691691
})
692692
}
693693

694-
func (s *Session) KeepAlive() error {
695-
if err := s.api.KeepAliveSession(context.TODO(), s.UID); err != nil {
694+
func (s *Session) KeepAlive(ctx context.Context) error {
695+
if err := s.api.KeepAliveSession(ctx, s.UID); err != nil {
696696
log.WithError(err).
697697
WithFields(log.Fields{"session": s.UID, "sshid": s.SSHID}).
698698
Error("Error when trying to keep alive the session")

0 commit comments

Comments
 (0)