From 665815b62730523666a80d68f8fbb27e6fe7425e Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Tue, 6 Nov 2018 22:35:48 +0800 Subject: [PATCH] enhance: update v1/v2 runtime 1. avoid dead lock during kill, fetch allProcesses before handle events 2. use argu's ctx instead of context.Backgroud() in openlog Signed-off-by: Wei Fu --- linux/shim/service.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/linux/shim/service.go b/linux/shim/service.go index 0abbdd2879d4..595145931d08 100644 --- a/linux/shim/service.go +++ b/linux/shim/service.go @@ -451,10 +451,19 @@ func (s *Service) processExits() { } } -func (s *Service) checkProcesses(e runc.Exit) { +func (s *Service) allProcesses() []proc.Process { s.mu.Lock() defer s.mu.Unlock() + + res := make([]proc.Process, 0, len(s.processes)) for _, p := range s.processes { + res = append(res, p) + } + return res +} + +func (s *Service) checkProcesses(e runc.Exit) { + for _, p := range s.allProcesses() { if p.Pid() == e.Pid { if ip, ok := p.(*proc.Init); ok { // Ensure all children are killed