chiark / gitweb /
path: properly free PathSpec structs
[elogind.git] / src / job.c
index ac3bb9d72962c53655c3b671ea828b1febe7a49f..79189f04da101db1ed8188ea95601c6e1c64f8cd 100644 (file)
--- a/src/job.c
+++ b/src/job.c
@@ -385,6 +385,9 @@ int job_run_and_invalidate(Job *j) {
 
                 case JOB_START:
                         r = unit_start(j->unit);
+
+                        /* If this unit cannot be started, then simply
+                         * wait */
                         if (r == -EBADR)
                                 r = 0;
                         break;
@@ -402,6 +405,11 @@ int job_run_and_invalidate(Job *j) {
 
                 case JOB_STOP:
                         r = unit_stop(j->unit);
+
+                        /* If this unit cannot stopped, then simply
+                         * wait. */
+                        if (r == -EBADR)
+                                r = 0;
                         break;
 
                 case JOB_RELOAD:
@@ -478,14 +486,18 @@ int job_finish_and_invalidate(Job *j, bool success) {
                 return 0;
         }
 
+        j->failed = !success;
+
         log_debug("Job %s/%s finished, success=%s", j->unit->meta.id, job_type_to_string(j->type), yes_no(success));
 
-        j->failed = !success;
+        if (j->failed)
+                j->manager->n_failed_jobs ++;
+
         u = j->unit;
         t = j->type;
         job_free(j);
 
-        if (!success)
+        if (!success && j->type == JOB_START)
                 unit_status_printf(u, "Starting %s " ANSI_HIGHLIGHT_ON "failed" ANSI_HIGHLIGHT_OFF ".\n", unit_description(u));
 
         /* Fail depending jobs on failure */
@@ -496,35 +508,31 @@ 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 &&
-                                    !other->meta.job->override &&
+                        SET_FOREACH(other, u->meta.dependencies[UNIT_BOUND_BY], i)
+                                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);
 
-                } else if (t == JOB_STOP) {
-
-                        SET_FOREACH(other, u->meta.dependencies[UNIT_CONFLICTS], i)
-                                if (!other->meta.ignore_dependency_failure &&
-                                    other->meta.job &&
+                        SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i)
+                                if (other->meta.job &&
+                                    !other->meta.job->override &&
                                     (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 &&
+                } else if (t == JOB_STOP) {
+
+                        SET_FOREACH(other, u->meta.dependencies[UNIT_CONFLICTS], i)
+                                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))