diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-09-14 01:51:30 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-09-14 01:51:30 +0200 |
commit | bba34eedc7fb8f5023fa0d55c23d00d5854546c5 (patch) | |
tree | 1ca2aa105afecdd1958713f539f69a7e412086d2 /src/unit.c | |
parent | 83a95334c9e1841595f5eef20938dbd0e1ad7f76 (diff) |
target: add implicit target/unit ordering deps only if both sides have been fully loaded
Diffstat (limited to 'src/unit.c')
-rw-r--r-- | src/unit.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/unit.c b/src/unit.c index ca15c257e8..5a451c57c2 100644 --- a/src/unit.c +++ b/src/unit.c @@ -726,13 +726,19 @@ int unit_load_fragment_and_dropin_optional(Unit *u) { return 0; } -static int unit_add_one_default_dependency(Unit *u, Unit *target) { +int unit_add_default_target_dependency(Unit *u, Unit *target) { assert(u); assert(target); if (target->meta.type != UNIT_TARGET) return 0; + /* Only add the dependency if boths units are loaded, so that + * that loop check below is reliable */ + if (u->meta.load_state != UNIT_LOADED || + target->meta.load_state != UNIT_LOADED) + return 0; + /* Don't create loops */ if (set_get(target->meta.dependencies[UNIT_BEFORE], u)) return 0; @@ -741,22 +747,22 @@ static int unit_add_one_default_dependency(Unit *u, Unit *target) { } static int unit_add_default_dependencies(Unit *u) { - Unit *other; + Unit *target; Iterator i; int r; assert(u); - SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i) - if ((r = unit_add_one_default_dependency(u, other)) < 0) + SET_FOREACH(target, u->meta.dependencies[UNIT_REQUIRED_BY], i) + if ((r = unit_add_default_target_dependency(u, target)) < 0) return r; - SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i) - if ((r = unit_add_one_default_dependency(u, other)) < 0) + SET_FOREACH(target, u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i) + if ((r = unit_add_default_target_dependency(u, target)) < 0) return r; - SET_FOREACH(other, u->meta.dependencies[UNIT_WANTED_BY], i) - if ((r = unit_add_one_default_dependency(u, other)) < 0) + SET_FOREACH(target, u->meta.dependencies[UNIT_WANTED_BY], i) + if ((r = unit_add_default_target_dependency(u, target)) < 0) return r; return 0; |