]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: make unit_start() return a distinguishable error code in case conditions didn...
authorLennart Poettering <lennart@poettering.net>
Wed, 14 Nov 2018 10:38:51 +0000 (11:38 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 16 Nov 2018 14:22:48 +0000 (15:22 +0100)
Ideally we'd even propagate this all the way to the client, by having a
separate JobType enum value for this. But it's hard to add this without
breaking compat, hence for now let's at least internally propagate this
case differently from the case "already on it".

This is then used to call job_finish_and_invalidate() slightly
differently, with the already= parameter false, as in the failed
condition case no message was likely produced so far.

src/core/job.c
src/core/manager.c
src/core/unit.c

index 48d60af82bbb05b88de6fdf7560d9fc02554045b..fc3d8d8308a9f536a8e2d4aaef5c1fa6e1c26699 100644 (file)
@@ -714,8 +714,10 @@ int job_run_and_invalidate(Job *j) {
         if (j) {
                 if (r == -EAGAIN)
                         job_set_state(j, JOB_WAITING); /* Hmm, not ready after all, let's return to JOB_WAITING state */
-                else if (r == -EALREADY)
+                else if (r == -EALREADY) /* already being executed */
                         r = job_finish_and_invalidate(j, JOB_DONE, true, true);
+                else if (r == -ECOMM)    /* condition failed, but all is good */
+                        r = job_finish_and_invalidate(j, JOB_DONE, true, false);
                 else if (r == -EBADR)
                         r = job_finish_and_invalidate(j, JOB_SKIPPED, true, false);
                 else if (r == -ENOEXEC)
index 3150740e05ade46cbda70f26e252585285edc161..11c353076c79f495b7a581c5954a93d693d9d18b 100644 (file)
@@ -2138,7 +2138,7 @@ static int manager_dispatch_run_queue(sd_event_source *source, void *userdata) {
                 assert(j->installed);
                 assert(j->in_run_queue);
 
-                job_run_and_invalidate(j);
+                (void) job_run_and_invalidate(j);
         }
 
         if (m->n_running_jobs > 0)
index c4d55dc2d3b84f46bcdaf25ee169c13603d9b90f..ab057ada8799658b84d0ada06ef57b9d437b4507 100644 (file)
@@ -1726,7 +1726,7 @@ int unit_start(Unit *u) {
         if (state != UNIT_ACTIVATING &&
             !unit_condition_test(u)) {
                 log_unit_debug(u, "Starting requested but condition failed. Not starting unit.");
-                return -EALREADY;
+                return -ECOMM;
         }
 
         /* If the asserts failed, fail the entire job */