Wait for all services to complete before changing runlevel

We allow all run/task/services to complete before changing runlevel.
This means stepping them all while we wait for their completion, since
services may depend on each other.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2018-10-03 08:40:23 +02:00
parent 231b887b2a
commit 060de93b5b
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -481,6 +481,9 @@ int main(int argc, char* argv[])
api_init(&loop);
umask(022);
/* Finalize bootstrap, allow service/run/tasks to complete */
service_step_all(SVC_TYPE_ANY);
/*
* Wait for all SVC_TYPE_RUNTASK to have completed their work in
* [S], or timeout, before calling finalize()
+3
View File
@@ -1267,6 +1267,9 @@ void service_bootstrap_cb(uev_t *w, void *arg, int events)
static int cnt = 120;
void (*finalize)(void) = arg;
_d("Step all services ...");
service_step_all(SVC_TYPE_ANY);
_d("Checking completion of all run/task ... %d", cnt);
if (cnt-- > 0 && !service_runtask_completed(!runlevel))
return;