]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: make sure "systemctl reload-or-try-restart is actually a noop if a unit is...
authorLennart Poettering <lennart@poettering.net>
Thu, 28 Jan 2016 17:48:42 +0000 (18:48 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 28 Jan 2016 17:48:42 +0000 (18:48 +0100)
This makes sure we follow the same basic logic for try-restart if we have a try-reload.

Fixes #688

src/core/dbus-unit.c
src/core/job.c
src/core/job.h
src/core/unit.c

index e4d2c08972c19c6cc2e4b6f6b77fe3e040315f0d..386ea96d1beba501ef4d950e7b4b80f39e14e385 100644 (file)
@@ -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(
index 274c554da91b0f43cda20f4ca65a97a0cac0db42..4e111ffb46cc6c2aab9a8c8ff62f9f3ee346334a 100644 (file)
@@ -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",
 };
 
index 118b24e5b712eccfa53afa3df7c24594c3beb94b..52866fdc480ab26be8af8035e29473b57f0a8e51 100644 (file)
@@ -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
index 32267d95f53159826f3c13e966759f92d80c1eff..b6fbf4e785ce224a5a25492cd219d409a8135f96 100644 (file)
@@ -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: