/*
- Copyright (C) 2015-2019 IoT.bzh
+ Copyright (C) 2015-2020 IoT.bzh
author: José Bollo <jose.bollo@iot.bzh>
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;
}
/*
*
* Returns the list or NULL in case of error.
*/
-struct json_object *afm_urun_list(struct afm_udb *db, int uid)
+struct json_object *afm_urun_list(struct afm_udb *db, int all, int uid)
{
int i, n, isuser, pid;
const char *udpath;
if (result == NULL)
goto error;
- apps = afm_udb_applications_private(db, uid);
+ apps = afm_udb_applications_private(db, all, uid);
n = json_object_array_length(apps);
for (i = 0 ; i < n ; i++) {
appli = json_object_array_get_idx(apps, i);
WARNING("searched runid %d not found", runid);
} else {
/* search in the base */
- apps = afm_udb_applications_private(db, uid);
+ apps = afm_udb_applications_private(db, 1, uid);
n = json_object_array_length(apps);
for (i = 0 ; i < n ; i++) {
appli = json_object_array_get_idx(apps, i);