From ead8e4788ee31bbdc38b4cd3c6e71c8a95bbc95a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 29 Oct 2010 01:15:18 +0200 Subject: [PATCH] unit: get rid of gnoreDependencyFailure= instead treat ConflictedBy= as weaker counterpart of Conflicts=, similar to Wants= vs. Requires= --- man/systemd.unit.xml | 14 -------------- src/automount.c | 2 +- src/job.c | 17 +++-------------- src/load-fragment.c | 1 - src/manager.c | 2 +- src/mount.c | 2 +- src/path.c | 2 +- src/service.c | 4 ++-- src/socket.c | 2 +- src/swap.c | 2 +- src/target.c | 2 +- src/timer.c | 2 +- src/unit.c | 6 ++---- src/unit.h | 3 --- units/final.target | 1 - units/shutdown.target | 1 - units/umount.target | 1 - 17 files changed, 15 insertions(+), 49 deletions(-) diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index ff1b47f9..4e1d9f30 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -543,20 +543,6 @@ ones. - - IgnoreDependencyFailure= - - Takes a boolean - argument. If and - a requirement dependency of this unit - fails to start up this unit will be - started nonetheless, ignoring that - failure. If - (the default) and a dependency unit - fails the unit will immediately fail - too and the job is removed. - - JobTimeoutSec= diff --git a/src/automount.c b/src/automount.c index da66630f..462f3170 100644 --- a/src/automount.c +++ b/src/automount.c @@ -154,7 +154,7 @@ static int automount_add_default_dependencies(Automount *a) { if (a->meta.manager->running_as == MANAGER_SYSTEM) { - if ((r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0) + if ((r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0) return r; } diff --git a/src/job.c b/src/job.c index 0b6d321e..8a74f8b6 100644 --- a/src/job.c +++ b/src/job.c @@ -500,16 +500,14 @@ int job_finish_and_invalidate(Job *j, bool success) { t == JOB_RELOAD_OR_START) { SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i) - if (!other->meta.ignore_dependency_failure && - other->meta.job && + if (other->meta.job && (other->meta.job->type == JOB_START || other->meta.job->type == JOB_VERIFY_ACTIVE || other->meta.job->type == JOB_RELOAD_OR_START)) job_finish_and_invalidate(other->meta.job, false); SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i) - if (!other->meta.ignore_dependency_failure && - other->meta.job && + if (other->meta.job && !other->meta.job->override && (other->meta.job->type == JOB_START || other->meta.job->type == JOB_VERIFY_ACTIVE || @@ -519,16 +517,7 @@ int job_finish_and_invalidate(Job *j, bool success) { } else if (t == JOB_STOP) { SET_FOREACH(other, u->meta.dependencies[UNIT_CONFLICTS], i) - if (!other->meta.ignore_dependency_failure && - other->meta.job && - (other->meta.job->type == JOB_START || - other->meta.job->type == JOB_VERIFY_ACTIVE || - other->meta.job->type == JOB_RELOAD_OR_START)) - job_finish_and_invalidate(other->meta.job, false); - - SET_FOREACH(other, u->meta.dependencies[UNIT_CONFLICTED_BY], i) - if (!other->meta.ignore_dependency_failure && - other->meta.job && + if (other->meta.job && (other->meta.job->type == JOB_START || other->meta.job->type == JOB_VERIFY_ACTIVE || other->meta.job->type == JOB_RELOAD_OR_START)) diff --git a/src/load-fragment.c b/src/load-fragment.c index 828b8d2a..4f94c640 100644 --- a/src/load-fragment.c +++ b/src/load-fragment.c @@ -1775,7 +1775,6 @@ static int load_from_path(Unit *u, const char *path) { { "RefuseManualStop", config_parse_bool, &u->meta.refuse_manual_stop, "Unit" }, { "AllowIsolate", config_parse_bool, &u->meta.allow_isolate, "Unit" }, { "DefaultDependencies", config_parse_bool, &u->meta.default_dependencies, "Unit" }, - { "IgnoreDependencyFailure",config_parse_bool, &u->meta.ignore_dependency_failure, "Unit" }, { "JobTimeoutSec", config_parse_usec, &u->meta.job_timeout, "Unit" }, { "ConditionPathExists", config_parse_condition_path, u, "Unit" }, { "ConditionKernelCommandLine", config_parse_condition_kernel, u, "Unit" }, diff --git a/src/manager.c b/src/manager.c index 796d3cbe..9fa48770 100644 --- a/src/manager.c +++ b/src/manager.c @@ -1483,7 +1483,7 @@ static int transaction_add_job_and_dependencies( goto fail; SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_CONFLICTED_BY], i) - if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, dep, ret, true, override, false, e, NULL)) < 0 && r != -EBADR) + if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, dep, ret, false, override, false, e, NULL)) < 0 && r != -EBADR) goto fail; } else if (type == JOB_STOP || type == JOB_RESTART || type == JOB_TRY_RESTART) { diff --git a/src/mount.c b/src/mount.c index d62ce8f4..2f966258 100644 --- a/src/mount.c +++ b/src/mount.c @@ -398,7 +398,7 @@ static int mount_add_default_dependencies(Mount *m) { if ((r = unit_add_dependency_by_name(UNIT(m), UNIT_BEFORE, SPECIAL_QUOTACHECK_SERVICE, NULL, true)) < 0) return r; - if ((r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0) + if ((r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0) return r; } diff --git a/src/path.c b/src/path.c index b3bc8a5a..1d6f98cf 100644 --- a/src/path.c +++ b/src/path.c @@ -110,7 +110,7 @@ static int path_add_default_dependencies(Path *p) { if ((r = unit_add_two_dependencies_by_name(UNIT(p), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0) return r; - return unit_add_two_dependencies_by_name(UNIT(p), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_SHUTDOWN_TARGET, NULL, true); + return unit_add_two_dependencies_by_name(UNIT(p), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true); } static int path_load(Unit *u) { diff --git a/src/service.c b/src/service.c index 49bdae72..d3c750e5 100644 --- a/src/service.c +++ b/src/service.c @@ -1021,7 +1021,7 @@ static int service_add_default_dependencies(Service *s) { } /* Second, activate normal shutdown */ - return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_SHUTDOWN_TARGET, NULL, true); + return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true); } static int service_load(Unit *u) { @@ -3017,7 +3017,7 @@ static int service_enumerate(Manager *m) { if (service->meta.fragment_path) continue; - if ((r = unit_add_two_dependencies_by_name_inverse(service, UNIT_AFTER, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true)) < 0) + if ((r = unit_add_two_dependencies_by_name(service, UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true)) < 0) goto finish; } diff --git a/src/socket.c b/src/socket.c index e8c016cc..6d2df958 100644 --- a/src/socket.c +++ b/src/socket.c @@ -305,7 +305,7 @@ static int socket_add_default_dependencies(Socket *s) { if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0) return r; - return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_SHUTDOWN_TARGET, NULL, true); + return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true); } static int socket_load(Unit *u) { diff --git a/src/swap.c b/src/swap.c index 078ad9fb..ddda9e1a 100644 --- a/src/swap.c +++ b/src/swap.c @@ -211,7 +211,7 @@ static int swap_add_default_dependencies(Swap *s) { if (s->meta.manager->running_as == MANAGER_SYSTEM) { - if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0) + if ((r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0) return r; } diff --git a/src/target.c b/src/target.c index 3522bf12..f322ce72 100644 --- a/src/target.c +++ b/src/target.c @@ -77,7 +77,7 @@ static int target_add_default_dependencies(Target *t) { return r; /* Make sure targets are unloaded on shutdown */ - return unit_add_dependency_by_name(UNIT(t), UNIT_CONFLICTED_BY, SPECIAL_SHUTDOWN_TARGET, NULL, true); + return unit_add_dependency_by_name(UNIT(t), UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true); } static int target_add_getty_dependencies(Target *t) { diff --git a/src/timer.c b/src/timer.c index 627a360f..065e9c14 100644 --- a/src/timer.c +++ b/src/timer.c @@ -82,7 +82,7 @@ static int timer_add_default_dependencies(Timer *t) { if ((r = unit_add_two_dependencies_by_name(UNIT(t), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0) return r; - return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_SHUTDOWN_TARGET, NULL, true); + return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true); } static int timer_load(Unit *u) { diff --git a/src/unit.c b/src/unit.c index fb5583bf..410ff9f6 100644 --- a/src/unit.c +++ b/src/unit.c @@ -655,13 +655,11 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { "%s\tStopWhenUnneeded: %s\n" "%s\tRefuseManualStart: %s\n" "%s\tRefuseManualStop: %s\n" - "%s\tDefaultDependencies: %s\n" - "%s\tIgnoreDependencyFailure: %s\n", + "%s\tDefaultDependencies: %s\n", prefix, yes_no(u->meta.stop_when_unneeded), prefix, yes_no(u->meta.refuse_manual_start), prefix, yes_no(u->meta.refuse_manual_stop), - prefix, yes_no(u->meta.default_dependencies), - prefix, yes_no(u->meta.ignore_dependency_failure)); + prefix, yes_no(u->meta.default_dependencies)); LIST_FOREACH(by_unit, b, u->meta.cgroup_bondings) fprintf(f, "%s\tControlGroup: %s:%s\n", diff --git a/src/unit.h b/src/unit.h index ff115118..796aee5b 100644 --- a/src/unit.h +++ b/src/unit.h @@ -199,9 +199,6 @@ struct Meta { /* Create default depedencies */ bool default_dependencies; - /* Bring up this unit even if a dependency fails to start */ - bool ignore_dependency_failure; - /* Refuse manual starting, allow starting only indirectly via dependency. */ bool refuse_manual_start; diff --git a/units/final.target b/units/final.target index ba642615..9cfda197 100644 --- a/units/final.target +++ b/units/final.target @@ -11,5 +11,4 @@ Description=Final Step DefaultDependencies=no RefuseManualStart=yes -IgnoreDependencyFailure=yes After=shutdown.target umount.target diff --git a/units/shutdown.target b/units/shutdown.target index 4db9f1fb..99a659e9 100644 --- a/units/shutdown.target +++ b/units/shutdown.target @@ -11,4 +11,3 @@ Description=Shutdown DefaultDependencies=no RefuseManualStart=yes -IgnoreDependencyFailure=yes diff --git a/units/umount.target b/units/umount.target index b5a993f0..b9ecca6f 100644 --- a/units/umount.target +++ b/units/umount.target @@ -11,4 +11,3 @@ Description=Unmount All Filesystems DefaultDependencies=no RefuseManualStart=yes -IgnoreDependencyFailure=yes -- 2.39.5