X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=job.c;h=5e250d58f0ca0b9caca6c1aaaf7b3de8c07394ec;hp=e2354af3fc1a2305c5ebcdeb41ab56c0c1682675;hb=aab14b13b491c08aa3ab0c3c59b2f3885692ffea;hpb=b866264a18095d5302443ab0a95560d973ba4b10 diff --git a/job.c b/job.c index e2354af3f..5e250d58f 100644 --- a/job.c +++ b/job.c @@ -65,7 +65,7 @@ void job_free(Job *j) { } /* Detach from next 'smaller' objects */ - manager_transaction_unlink_job(j->manager, j); + manager_transaction_unlink_job(j->manager, j, true); if (j->in_run_queue) LIST_REMOVE(Job, run_queue, j->manager->run_queue, j); @@ -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; @@ -446,26 +485,26 @@ int job_finish_and_invalidate(Job *j, bool success) { SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i) if (other->meta.job && - (other->meta.type == JOB_START || - other->meta.type == JOB_VERIFY_ACTIVE || - other->meta.type == JOB_RELOAD_OR_START)) + (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_SOFT_REQUIRED_BY], i) if (other->meta.job && !other->meta.job->forced && - (other->meta.type == JOB_START || - other->meta.type == JOB_VERIFY_ACTIVE || - other->meta.type == JOB_RELOAD_OR_START)) + (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.job && - (t == JOB_START || - t == JOB_VERIFY_ACTIVE || - t == JOB_RELOAD_OR_START)) + (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); } }