From b3438f7a6f63849d2179a2a76b804aea460affd9 Mon Sep 17 00:00:00 2001 From: Lifubang Date: Sun, 18 Nov 2018 09:00:25 +0800 Subject: [PATCH 1/2] fix pipe in broken may cause shim lock forever for runtime v2 Signed-off-by: Lifubang --- runtime/v2/runc/service_linux.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/runtime/v2/runc/service_linux.go b/runtime/v2/runc/service_linux.go index 5e30cfcb3..19d1fec7d 100644 --- a/runtime/v2/runc/service_linux.go +++ b/runtime/v2/runc/service_linux.go @@ -49,9 +49,10 @@ func (p *linuxPlatform) CopyConsole(ctx context.Context, console console.Console cwg.Add(1) go func() { cwg.Done() - p := bufPool.Get().(*[]byte) - defer bufPool.Put(p) - io.CopyBuffer(epollConsole, in, *p) + bp := bufPool.Get().(*[]byte) + defer bufPool.Put(bp) + io.CopyBuffer(epollConsole, in, *bp) + epollConsole.Shutdown(p.epoller.CloseConsole) }() } From e76a8879eb10594113d70556c80dd2e456202e22 Mon Sep 17 00:00:00 2001 From: Lifubang Date: Mon, 19 Nov 2018 09:04:00 +0800 Subject: [PATCH 2/2] fix pipe in broken may cause shim lock forever for runtime v1 Signed-off-by: Lifubang --- runtime/v1/shim/service_linux.go | 8 +++++--- runtime/v2/runc/service_linux.go | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/runtime/v1/shim/service_linux.go b/runtime/v1/shim/service_linux.go index 18ae6503b..307e20dab 100644 --- a/runtime/v1/shim/service_linux.go +++ b/runtime/v1/shim/service_linux.go @@ -49,9 +49,11 @@ func (p *linuxPlatform) CopyConsole(ctx context.Context, console console.Console cwg.Add(1) go func() { cwg.Done() - p := bufPool.Get().(*[]byte) - defer bufPool.Put(p) - io.CopyBuffer(epollConsole, in, *p) + bp := bufPool.Get().(*[]byte) + defer bufPool.Put(bp) + io.CopyBuffer(epollConsole, in, *bp) + // we need to shutdown epollConsole when pipe broken + epollConsole.Shutdown(p.epoller.CloseConsole) }() } diff --git a/runtime/v2/runc/service_linux.go b/runtime/v2/runc/service_linux.go index 19d1fec7d..116167352 100644 --- a/runtime/v2/runc/service_linux.go +++ b/runtime/v2/runc/service_linux.go @@ -52,6 +52,7 @@ func (p *linuxPlatform) CopyConsole(ctx context.Context, console console.Console bp := bufPool.Get().(*[]byte) defer bufPool.Put(bp) io.CopyBuffer(epollConsole, in, *bp) + // we need to shutdown epollConsole when pipe broken epollConsole.Shutdown(p.epoller.CloseConsole) }() }