unit_check_unneeded(other);
}
-void unit_trigger_on_failure(Unit *u) {
+void unit_start_on_failure(Unit *u) {
Unit *other;
Iterator i;
}
}
+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;
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))
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);
}
}
}
manager_recheck_journal(m);
+ unit_trigger_notify(u);
/* Maybe we finished startup and are now ready for being
* stopped because unneeded? */
if (u->instance)
s = unit_name_replace_instance(name, u->instance);
else {
- char *i;
+ _cleanup_free_ char *i = NULL;
i = unit_name_to_prefix(u->id);
if (!i)
return NULL;
s = unit_name_replace_instance(name, i);
- free(i);
}
if (!s)
assert(u);
if (u->instance) {
- _cleanup_free_ char *t = NULL;
+ _cleanup_free_ char *t = NULL, *escaped_template = NULL, *escaped_instance = NULL;
t = unit_name_template(u->id);
if (!t)
return NULL;
- return strjoin(u->manager->cgroup_hierarchy, "/", t, "/", u->instance, NULL);
- } else
- return strjoin(u->manager->cgroup_hierarchy, "/", u->id, NULL);
+ escaped_template = cg_escape(t);
+ if (!escaped_template)
+ return NULL;
+
+ escaped_instance = cg_escape(u->id);
+ if (!escaped_instance)
+ return NULL;
+
+ return strjoin(u->manager->cgroup_hierarchy, "/", escaped_template, "/", escaped_instance, NULL);
+ } else {
+ _cleanup_free_ char *escaped = NULL;
+
+ escaped = cg_escape(u->id);
+ if (!escaped)
+ return NULL;
+
+ return strjoin(u->manager->cgroup_hierarchy, "/", escaped, NULL);
+ }
}
int unit_add_cgroup_from_text(Unit *u, const char *name, bool overwrite, CGroupBonding **ret) {