From d0933055cb01ecaab5428d9b5cbf276346a74297 Mon Sep 17 00:00:00 2001 From: anhoder Date: Fri, 27 May 2022 18:25:43 +0800 Subject: [PATCH] fix:goroutine leak when open terminal --- pkg/models/terminal/terminal.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/models/terminal/terminal.go b/pkg/models/terminal/terminal.go index dd5dff3bb..a2f3b60bc 100644 --- a/pkg/models/terminal/terminal.go +++ b/pkg/models/terminal/terminal.go @@ -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() }