From 0e3ac66e761f8d41c91b5d07c985cedfa40790c0 Mon Sep 17 00:00:00 2001 From: Alexandru Matei Date: Tue, 8 Nov 2022 21:05:22 +0200 Subject: [PATCH] clh: return faster with dead clh process from isClhRunning Through proactively checking if Cloud Hypervisor process is dead, this patch provides a faster path for isClhRunning Fixes: #5623 Signed-off-by: Alexandru Matei --- src/runtime/virtcontainers/clh.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index 3319f7b912..090e074755 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -1405,16 +1405,16 @@ func (clh *cloudHypervisor) isClhRunning(timeout uint) (bool, error) { return false, nil } - if err := syscall.Kill(pid, syscall.Signal(0)); err != nil { - return false, nil - } - timeStart := time.Now() cl := clh.client() for { + err := syscall.Kill(pid, syscall.Signal(0)) + if err != nil { + return false, nil + } ctx, cancel := context.WithTimeout(context.Background(), clh.getClhAPITimeout()*time.Second) - defer cancel() - _, _, err := cl.VmmPingGet(ctx) + _, _, err = cl.VmmPingGet(ctx) + cancel() if err == nil { return true, nil } else {