summaryrefslogtreecommitdiff
path: root/src/unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-10-13 02:15:41 +0200
committerLennart Poettering <lennart@poettering.net>2010-10-13 02:15:41 +0200
commit52661efd21608dc7e0ac26b714a9254ed6180ddb (patch)
tree5f64764566711e6a38a664cfc0ee9f9a997e4857 /src/unit.c
parente04aad61bb5eff117e51631727a3ef2807c75d6b (diff)
unit: add minimal condition checker for unit startup
Diffstat (limited to 'src/unit.c')
-rw-r--r--src/unit.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/unit.c b/src/unit.c
index 9fc9be5c79..07978134de 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -375,6 +375,8 @@ void unit_free(Unit *u) {
set_free_free(u->meta.names);
+ condition_free_list(u->meta.conditions);
+
free(u->meta.instance);
free(u);
}
@@ -639,6 +641,8 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
if (u->meta.job_timeout > 0)
fprintf(f, "%s\tJob Timeout: %s\n", prefix, format_timespan(timespan, sizeof(timespan), u->meta.job_timeout));
+ condition_dump_list(u->meta.conditions, f, prefix);
+
for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++) {
Unit *other;
@@ -840,6 +844,12 @@ int unit_start(Unit *u) {
if (!UNIT_VTABLE(u)->start)
return -EBADR;
+ /* If the conditions failed, don't do anything at all */
+ if (!condition_test_list(u->meta.conditions)) {
+ log_debug("Starting of %s requested but condition failed. Ignoring.", u->meta.id);
+ return -EALREADY;
+ }
+
/* We don't suppress calls to ->start() here when we are
* already starting, to allow this request to be used as a
* "hurry up" call, for example when the unit is in some "auto