mirror of
https://github.com/troglobit/finit.git
synced 2026-11-11 16:40:48 +00:00
Refactor dddd45e, schedule work to iterate over services again
Instead of changing the API of service_step(), and relying on all the
different callers to step again, we can schedule another event to do
this for us.
In addition to handling the cond_update() case this also handles all
other callers of service_step(). Ensuring that nested conditions do
trigger changes.
Also, reverting dddd45e fixes a minor regression in service_monitor()
which caused it to not clean up collected bootstrap tasks.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
1269f082de
commit
3006caf670
2 files changed
+46
-18
No files matched your search
+7
-11
@@ -140,23 +140,19 @@ static int svc_has_cond(svc_t *svc)
|
||||
static void cond_update(const char *name)
|
||||
{
|
||||
svc_t *svc, *iter = NULL;
|
||||
int restart = 0;
|
||||
|
||||
_d("%s", name);
|
||||
do {
|
||||
restart = 0;
|
||||
for (svc = svc_iterator(&iter, 1); svc; svc = svc_iterator(&iter, 0)) {
|
||||
if (!svc_has_cond(svc) || !cond_affects(name, svc->cond))
|
||||
continue;
|
||||
for (svc = svc_iterator(&iter, 1); svc; svc = svc_iterator(&iter, 0)) {
|
||||
if (!svc_has_cond(svc) || !cond_affects(name, svc->cond))
|
||||
continue;
|
||||
|
||||
_d("%s: match <%s> %s(%s)", name ?: "nil", svc->cond, svc->desc, svc->cmd);
|
||||
restart += service_step(svc);
|
||||
}
|
||||
} while (restart);
|
||||
_d("%s: match <%s> %s(%s)", name ?: "nil", svc->cond, svc->desc, svc->cmd);
|
||||
service_step(svc);
|
||||
}
|
||||
}
|
||||
|
||||
void cond_set(const char *name)
|
||||
{
|
||||
{
|
||||
_d("%s", name);
|
||||
if (string_compare(name, "nop"))
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user