fix:goroutine leak when open terminal

This commit is contained in:
anhoder
2022-05-27 18:25:43 +08:00
parent f6c1261900
commit d0933055cb

View File

@@ -71,6 +71,9 @@ type TerminalMessage struct {
func (t TerminalSession) Next() *remotecommand.TerminalSize {
select {
case size := <-t.sizeChan:
if size.Height == 0 && size.Width == 0 {
return nil
}
return &size
}
}
@@ -135,6 +138,7 @@ func (t TerminalSession) Toast(p string) error {
// For now the status code is unused and reason is shown to the user (unless "")
func (t TerminalSession) Close(status uint32, reason string) {
klog.Warning(status, reason)
close(t.sizeChan)
t.conn.Close()
}