aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-08-04 13:06:04 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-08-04 13:06:04 +0200
commitfa6875384e70f2c9bf2e871991db22839cf6fbd5 (patch)
tree6454a010775dfe812b169f3adcea861cb2a87e12
parent935db2757a85c9423a4c02f5cea19d77fd7264d3 (diff)
Try to do more robust machine shutdown
-rw-r--r--bbot/agent/machine.cxx21
1 files changed, 20 insertions, 1 deletions
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::