Track run/tasks, should run at least once per declared runlevel

This patch adds a 'once' counter to the svc_t for run/task jobs.  This
counter is incremented when Finit calls service_start() and is reset on
runlevel changes.

Also, at the end of a runlevel each run/task have their state reset to
SVC_HALTED_STATE so they can be launched again for the new runlevel, if
so declared.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2017-12-13 17:58:48 +01:00
1 parent 5117b723c2
commit 3c015f384d
4 files changed
+31 -2

No files matched your search

+24 -1
View File
@@ -274,7 +274,7 @@ static int service_start(svc_t *svc)
if (svc->inetd.cmd)
status = svc->inetd.cmd(svc->inetd.type);
else if (svc->type & SVC_TYPE_RUNTASK)
else if (svc_is_runtask(svc))
status = exec_runtask(svc->cmd, args);
else
status = execv(svc->cmd, args);
@@ -920,6 +920,11 @@ restart:
svc_set_state(svc, SVC_STOPPING_STATE);
break;
}
if (svc_is_runtask(svc)) {
svc->once++;
break;
}
}
cond = cond_get_agg(svc->cond);
@@ -995,6 +1000,24 @@ void service_step_all(int types)
svc_foreach_type(types, service_step);
}
/**
* svc_clean_runtask - Clear once flag of runtasks
*
* XXX: runtasks should be stopped before calling this
*/
void service_runtask_clean(void)
{
svc_t *svc;
for (svc = svc_iterator(1); svc; svc = svc_iterator(0)) {
if (!svc_is_runtask(svc))
continue;
svc->once = 0;
if (svc->state == SVC_DONE_STATE)
svc_set_state(svc, SVC_HALTED_STATE);
}
}
/**
* Local Variables:
* indent-tabs-mode: t