aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2020-05-06 13:48:17 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2020-05-07 15:26:46 +0200
commit4818e6c17dd8b9de2c998611297796a94d1e5f78 (patch)
treecb416d1247a1a1ab19c89c43ff2e3b0047b51a0c
parent381a0973c9d421bc031882cecce9244f6d2a6638 (diff)
afm-urun: Fix infinite loop on start status
Ensure that there is no infinite loop when waiting for the completion of a status. Bug-AGL: SPEC-3323 Change-Id: I93537e9bbbe8ef357d112bea1cb6201e96d01ebf Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afm-urun.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/afm-urun.c b/src/afm-urun.c
index 227fd1d..7f8ad16 100644
--- a/src/afm-urun.c
+++ b/src/afm-urun.c
@@ -146,15 +146,18 @@ error:
static const char *wait_state_stable(int isuser, const char *dpath)
{
- const char *state;
+ int trial, count;
+ const char *state = NULL;
- for (;;) {
+ count = 10;
+ for (trial = 1 ; trial <= count ; trial++) {
state = systemd_unit_state_of_dpath(isuser, dpath);
if (state == NULL || state == SysD_State_Active
|| state == SysD_State_Failed)
return state;
- /* TODO: sleep */
+ sleep(1);
}
+ return state;
}
/*