summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-04-23 15:53:16 -0300
committerLennart Poettering <lennart@poettering.net>2013-04-23 16:00:32 -0300
commit3ecaa09bccd8a59c9f1e06756a1334a162206dc4 (patch)
tree5db15dc8f6fe6ea17e0d2449b8fee015b6066f47 /src/core/unit.c
parenta34cb32e54ed51125957f69622efef30f42d5fae (diff)
unit: rework trigger dependency logic
Instead of having explicit type-specific callbacks that inform the triggering unit when a triggered unit changes state, make this generic so that state changes are forwarded betwee any triggered and triggering unit. Also, get rid of UnitRef references from automount, timer, path units, to the units they trigger and rely exclsuively on UNIT_TRIGGER type dendencies.
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index 5834009445..4b9abf32dc 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1304,7 +1304,7 @@ static void check_unneeded_dependencies(Unit *u) {
unit_check_unneeded(other);
}
-void unit_trigger_on_failure(Unit *u) {
+void unit_start_on_failure(Unit *u) {
Unit *other;
Iterator i;
@@ -1324,6 +1324,17 @@ void unit_trigger_on_failure(Unit *u) {
}
}
+void unit_trigger_notify(Unit *u) {
+ Unit *other;
+ Iterator i;
+
+ assert(u);
+
+ SET_FOREACH(other, u->dependencies[UNIT_TRIGGERED_BY], i)
+ if (UNIT_VTABLE(other)->trigger_notify)
+ UNIT_VTABLE(other)->trigger_notify(other, u);
+}
+
void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_success) {
Manager *m;
bool unexpected;
@@ -1354,9 +1365,6 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
u->active_enter_timestamp = ts;
else if (UNIT_IS_ACTIVE_OR_RELOADING(os) && !UNIT_IS_ACTIVE_OR_RELOADING(ns))
u->active_exit_timestamp = ts;
-
- timer_unit_notify(u, ns);
- path_unit_notify(u, ns);
}
if (UNIT_IS_INACTIVE_OR_FAILED(ns))
@@ -1461,7 +1469,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
if (ns != os && ns == UNIT_FAILED) {
log_notice_unit(u->id,
"MESSAGE=Unit %s entered failed state.", u->id);
- unit_trigger_on_failure(u);
+ unit_start_on_failure(u);
}
}
@@ -1512,6 +1520,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
}
manager_recheck_journal(m);
+ unit_trigger_notify(u);
/* Maybe we finished startup and are now ready for being
* stopped because unneeded? */