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 <alexandru.matei@uipath.com>
(cherry picked from commit 9ef68e0c7a)
This commit is contained in:
Alexandru Matei 2022-11-10 14:08:14 +02:00 committed by Fabiano Fidêncio
parent fa8a0ad49b
commit 569ecdbe76

View File

@ -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
}