Move the "credit expired" loop exit to the middle of the loop,
immediately after "return true". This way having reached the goal on the
last iteration would be reported as success to the caller, rather than
as "timed out".
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
master commit:
d8f8cb8bdd02fad3b6986ae93511f750fa7f7e6a
master date: 2022-07-18 17:48:18 +0200
if (rc < 0)
return false;
- do {
+ for (;;) {
time_t start;
rc = libxl_get_free_memory(ctx, &free_memkb);
if (free_memkb >= need_memkb)
return true;
+ if (credit <= 0)
+ return false;
+
rc = libxl_set_memory_target(ctx, 0, free_memkb - need_memkb, 1, 0);
if (rc < 0)
return false;
return false;
credit -= difftime(time(NULL), start);
- } while (credit > 0);
-
- return false;
+ }
}
static void reload_domain_config(uint32_t domid,