From fa6875384e70f2c9bf2e871991db22839cf6fbd5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 4 Aug 2017 13:06:04 +0200 Subject: Try to do more robust machine shutdown --- bbot/agent/machine.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/bbot/agent/machine.cxx b/bbot/agent/machine.cxx index f3c9874..c2ded27 100644 --- a/bbot/agent/machine.cxx +++ b/bbot/agent/machine.cxx @@ -338,7 +338,26 @@ namespace bbot // Wait for up to the specified number if seconds for the machine to // shutdown. // - return wait (seconds); + // Since things sometimes get stuck for no apparent reason, keep repeating + // the the request every minute. + // + for (size_t s;; ) + { + s = 60; + bool r (seconds < s ? wait (seconds) : wait (s)); + seconds -= (60 - s); + + if (r || seconds == 0) + return r; + + try + { + monitor_command ("system_powerdown", false); + } + catch (const failed&) {} + } + + return false; } void kvm_machine:: -- cgit v1.1