Merge pull request #20 from github/jg/close-session-v2

Close RPC conn only
This commit is contained in:
Jose Garcia 2021-09-21 07:54:04 -04:00 committed by GitHub
commit 5e9382e8b4

View file

@ -15,16 +15,14 @@ type Session struct {
// Close should be called by users to clean up RPC and SSH resources whenever the session
// is no longer active.
func (s *Session) Close() error {
if err := s.rpc.Close(); err != nil {
// Closing the RPC conn closes the underlying stream (SSH)
// So we only need to close once
err := s.rpc.Close()
if err != nil {
s.ssh.Close() // close SSH and ignore error
return fmt.Errorf("failed to close RPC conn: %w", err)
}
if err := s.ssh.Close(); err != nil {
return fmt.Errorf("failed to close SSH conn: %w", err)
}
return nil
return err
}
// Port describes a port exposed by the container.