X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=job.c;h=c4d2e7a11e5c7a531a5e086abd9985568725a2c7;hb=5af98f828476716954f327c479c4cf6321ae3fe4;hp=be42eaff62f5ed9fcbad31131833bf1aa0b3cc04;hpb=c1e1601e8c6cace85b19a0eebe50076e5d119688;p=elogind.git diff --git a/job.c b/job.c index be42eaff6..c4d2e7a11 100644 --- 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; @@ -410,7 +449,7 @@ int job_run_and_invalidate(Job *j) { int job_finish_and_invalidate(Job *j, bool success) { Unit *u; Unit *other; - UnitType t; + JobType t; Iterator i; assert(j);