From 569ecdbe768bf7637aac96ef77dd7f2f88c57e6f Mon Sep 17 00:00:00 2001 From: Alexandru Matei Date: Thu, 10 Nov 2022 14:08:14 +0200 Subject: [PATCH] clh: fast exit from isClhRunning if the process was stopped Use atomic operations instead of acquiring a mutex in isClhRunning. This stops isClhRunning from generating a deadlock by trying to reacquire an already-acquired lock when called via StopVM->terminate. Signed-off-by: Alexandru Matei (cherry picked from commit 9ef68e0c7adc75e73e9a1b2827313c26c7551f51) --- src/runtime/virtcontainers/clh.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index 9562cf5d8a..45217a4a94 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -1397,6 +1397,10 @@ func (clh *cloudHypervisor) isClhRunning(timeout uint) (bool, error) { pid := clh.state.PID + if atomic.LoadInt32(&clh.stopped) != 0 { + return false, nil + } + if err := syscall.Kill(pid, syscall.Signal(0)); err != nil { return false, nil }