diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-01-28 19:11:30 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-01-28 19:11:30 -0500 |
commit | 2bc968b74843c3dc654a223eae8222505036c6c7 (patch) | |
tree | 797980331963fdb87e098d3f8e336a1b4bd2d289 /src | |
parent | 9e83569d8ff219730912ecac441843b9531b079c (diff) | |
parent | aabf5d42434082ae4e2d0c98d4705f58ee707567 (diff) |
Merge pull request #2464 from poettering/reload-or-try-restart
Fix for #688
Diffstat (limited to 'src')
-rw-r--r-- | src/core/dbus-unit.c | 2 | ||||
-rw-r--r-- | src/core/job.c | 8 | ||||
-rw-r--r-- | src/core/job.h | 3 | ||||
-rw-r--r-- | src/core/manager.c | 6 | ||||
-rw-r--r-- | src/core/transaction.c | 8 | ||||
-rw-r--r-- | src/core/unit.c | 2 | ||||
-rw-r--r-- | src/shared/bus-util.c | 2 | ||||
-rw-r--r-- | src/systemctl/systemctl.c | 5 |
8 files changed, 28 insertions, 8 deletions
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index e4d2c08972..386ea96d1b 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -987,7 +987,7 @@ int bus_unit_queue_job( if (type == JOB_RESTART) type = JOB_RELOAD_OR_START; else if (type == JOB_TRY_RESTART) - type = JOB_RELOAD; + type = JOB_TRY_RELOAD; } r = mac_selinux_unit_access_check( diff --git a/src/core/job.c b/src/core/job.c index 274c554da9..4e111ffb46 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -405,6 +405,13 @@ JobType job_type_collapse(JobType t, Unit *u) { return JOB_RESTART; + case JOB_TRY_RELOAD: + s = unit_active_state(u); + if (UNIT_IS_INACTIVE_OR_DEACTIVATING(s)) + return JOB_NOP; + + return JOB_RELOAD; + case JOB_RELOAD_OR_START: s = unit_active_state(u); if (UNIT_IS_INACTIVE_OR_DEACTIVATING(s)) @@ -1202,6 +1209,7 @@ static const char* const job_type_table[_JOB_TYPE_MAX] = { [JOB_RELOAD_OR_START] = "reload-or-start", [JOB_RESTART] = "restart", [JOB_TRY_RESTART] = "try-restart", + [JOB_TRY_RELOAD] = "try-reload", [JOB_NOP] = "nop", }; diff --git a/src/core/job.h b/src/core/job.h index 118b24e5b7..52866fdc48 100644 --- a/src/core/job.h +++ b/src/core/job.h @@ -66,6 +66,9 @@ enum JobType { * Thus we never need to merge it with anything. */ JOB_TRY_RESTART = _JOB_TYPE_MAX_IN_TRANSACTION, /* if running, stop and then start */ + /* Similar to JOB_TRY_RESTART but collapses to JOB_RELOAD or JOB_NOP */ + JOB_TRY_RELOAD, + /* JOB_RELOAD_OR_START won't enter into a transaction and cannot result * from transaction merging (there's no way for JOB_RELOAD and * JOB_START to meet in one transaction). It can result from a merge diff --git a/src/core/manager.c b/src/core/manager.c index a83a8b013a..e8fea376ff 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -3097,18 +3097,18 @@ ManagerState manager_state(Manager *m) { /* Is the special shutdown target queued? If so, we are in shutdown state */ u = manager_get_unit(m, SPECIAL_SHUTDOWN_TARGET); - if (u && u->job && IN_SET(u->job->type, JOB_START, JOB_RESTART, JOB_TRY_RESTART, JOB_RELOAD_OR_START)) + if (u && u->job && IN_SET(u->job->type, JOB_START, JOB_RESTART, JOB_RELOAD_OR_START)) return MANAGER_STOPPING; /* Are the rescue or emergency targets active or queued? If so we are in maintenance state */ u = manager_get_unit(m, SPECIAL_RESCUE_TARGET); if (u && (UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u)) || - (u->job && IN_SET(u->job->type, JOB_START, JOB_RESTART, JOB_TRY_RESTART, JOB_RELOAD_OR_START)))) + (u->job && IN_SET(u->job->type, JOB_START, JOB_RESTART, JOB_RELOAD_OR_START)))) return MANAGER_MAINTENANCE; u = manager_get_unit(m, SPECIAL_EMERGENCY_TARGET); if (u && (UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u)) || - (u->job && IN_SET(u->job->type, JOB_START, JOB_RESTART, JOB_TRY_RESTART, JOB_RELOAD_OR_START)))) + (u->job && IN_SET(u->job->type, JOB_START, JOB_RESTART, JOB_RELOAD_OR_START)))) return MANAGER_MAINTENANCE; /* Are there any failed units? If so, we are in degraded mode */ diff --git a/src/core/transaction.c b/src/core/transaction.c index 8b0ed74643..0d53e4bac0 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -1010,7 +1010,13 @@ int transaction_add_job_and_dependencies( if (type == JOB_RELOAD) { SET_FOREACH(dep, ret->unit->dependencies[UNIT_PROPAGATES_RELOAD_TO], i) { - r = transaction_add_job_and_dependencies(tr, JOB_RELOAD, dep, ret, false, false, false, ignore_order, e); + JobType nt; + + nt = job_type_collapse(JOB_TRY_RELOAD, dep); + if (nt == JOB_NOP) + continue; + + r = transaction_add_job_and_dependencies(tr, nt, dep, ret, false, false, false, ignore_order, e); if (r < 0) { log_unit_warning(dep, "Cannot add dependency reload job, ignoring: %s", diff --git a/src/core/unit.c b/src/core/unit.c index 32267d95f5..b6fbf4e785 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1894,6 +1894,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su case JOB_RELOAD: case JOB_RELOAD_OR_START: + case JOB_TRY_RELOAD: if (u->job->state == JOB_RUNNING) { if (ns == UNIT_ACTIVE) @@ -2107,6 +2108,7 @@ bool unit_job_is_applicable(Unit *u, JobType j) { return unit_can_start(u); case JOB_RELOAD: + case JOB_TRY_RELOAD: return unit_can_reload(u); case JOB_RELOAD_OR_START: diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index b9a8ee4074..63fd9b9514 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -2100,7 +2100,7 @@ static int check_wait_response(BusWaitForJobs *d, bool quiet, const char *extra_ else if (streq(d->result, "dependency")) log_error("A dependency job for %s failed. See 'journalctl -xe' for details.", strna(d->name)); else if (streq(d->result, "invalid")) - log_error("Job for %s invalid.", strna(d->name)); + log_error("%s is not active, cannot reload.", strna(d->name)); else if (streq(d->result, "assert")) log_error("Assertion failed on job for %s.", strna(d->name)); else if (streq(d->result, "unsupported")) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 12209dc99b..f5703af241 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -2538,6 +2538,7 @@ static const struct { { "try-restart", "TryRestartUnit" }, { "condrestart", "TryRestartUnit" }, { "reload-or-restart", "ReloadOrRestartUnit" }, + { "try-reload-or-restart", "ReloadOrTryRestartUnit" }, { "reload-or-try-restart", "ReloadOrTryRestartUnit" }, { "condreload", "ReloadOrTryRestartUnit" }, { "force-reload", "ReloadOrTryRestartUnit" } @@ -6234,8 +6235,8 @@ static void systemctl_help(void) { " try-restart NAME... Restart one or more units if active\n" " reload-or-restart NAME... Reload one or more units if possible,\n" " otherwise start or restart\n" - " reload-or-try-restart NAME... Reload one or more units if possible,\n" - " otherwise restart if active\n" + " try-reload-or-restart NAME... If active, reload one or more units,\n" + " if supported, otherwise restart\n" " isolate NAME Start one unit and stop all others\n" " kill NAME... Send signal to processes of a unit\n" " is-active PATTERN... Check whether units are active\n" |