]> err.no Git - systemd/commitdiff
job: define job_type_is_redundant() to idenity unnecessary jobs
authorLennart Poettering <lennart@poettering.net>
Tue, 6 Apr 2010 00:39:16 +0000 (02:39 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 6 Apr 2010 00:39:16 +0000 (02:39 +0200)
job.c
job.h

diff --git a/job.c b/job.c
index e2354af3fc1a2305c5ebcdeb41ab56c0c1682675..c4d2e7a11e5c7a531a5e086abd9985568725a2c7 100644 (file)
--- a/job.c
+++ b/job.c
@@ -265,6 +265,45 @@ bool job_type_is_conflicting(JobType a, JobType b) {
         return (a == JOB_STOP) != (b == JOB_STOP);
 }
 
+bool job_type_is_redundant(JobType a, UnitActiveState b) {
+        switch (a) {
+
+        case JOB_START:
+                return
+                        b == UNIT_ACTIVE ||
+                        b == UNIT_ACTIVE_RELOADING;
+
+        case JOB_STOP:
+                return
+                        b == UNIT_INACTIVE;
+
+        case JOB_VERIFY_ACTIVE:
+                return
+                        b == UNIT_ACTIVE ||
+                        b == UNIT_ACTIVE_RELOADING;
+
+        case JOB_RELOAD:
+                return
+                        b == UNIT_ACTIVE_RELOADING;
+
+        case JOB_RELOAD_OR_START:
+                return
+                        b == UNIT_ACTIVATING ||
+                        b == UNIT_ACTIVE_RELOADING;
+
+        case JOB_RESTART:
+                return
+                        b == UNIT_ACTIVATING;
+
+        case JOB_TRY_RESTART:
+                return
+                        b == UNIT_ACTIVATING;
+
+        default:
+                assert_not_reached("Invalid job type");
+        }
+}
+
 bool job_is_runnable(Job *j) {
         Iterator i;
         Unit *other;
diff --git a/job.h b/job.h
index bfe20339ece02aa5277159aa9ea12c90e46e5ac3..5bea2948c7b1b922afc0627595b17a56dc775beb 100644 (file)
--- a/job.h
+++ b/job.h
@@ -126,6 +126,7 @@ int job_type_merge(JobType *a, JobType b);
 bool job_type_is_mergeable(JobType a, JobType b);
 bool job_type_is_superset(JobType a, JobType b);
 bool job_type_is_conflicting(JobType a, JobType b);
+bool job_type_is_redundant(JobType a, UnitActiveState b);
 
 bool job_is_runnable(Job *j);