unit: if a unit external changes state, consider that good enough for a job to succeed, don't enforce waiting for the dependencies

This commit is contained in:
Lennart Poettering 2010-06-04 20:13:05 +02:00
parent 2149e37c79
commit b410e6b951

View file

@ -969,56 +969,54 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns) {
* failed previously due to EAGAIN. */ * failed previously due to EAGAIN. */
job_add_to_run_queue(u->meta.job); job_add_to_run_queue(u->meta.job);
else {
assert(u->meta.job->state == JOB_RUNNING);
/* Let's check whether this state change /* Let's check whether this state change constitutes a
* constitutes a finished job, or maybe * finished job, or maybe cotradicts a running job and
* cotradicts a running job and hence needs to * hence needs to invalidate jobs. */
* invalidate jobs. */
switch (u->meta.job->type) { switch (u->meta.job->type) {
case JOB_START: case JOB_START:
case JOB_VERIFY_ACTIVE: case JOB_VERIFY_ACTIVE:
if (UNIT_IS_ACTIVE_OR_RELOADING(ns)) if (UNIT_IS_ACTIVE_OR_RELOADING(ns))
job_finish_and_invalidate(u->meta.job, true); job_finish_and_invalidate(u->meta.job, true);
else if (ns != UNIT_ACTIVATING) { else if (u->meta.job->state == JOB_RUNNING && ns != UNIT_ACTIVATING) {
unexpected = true; unexpected = true;
job_finish_and_invalidate(u->meta.job, false); job_finish_and_invalidate(u->meta.job, false);
} }
break; break;
case JOB_RELOAD: case JOB_RELOAD:
case JOB_RELOAD_OR_START: case JOB_RELOAD_OR_START:
if (u->meta.job->state == JOB_RUNNING) {
if (ns == UNIT_ACTIVE) if (ns == UNIT_ACTIVE)
job_finish_and_invalidate(u->meta.job, true); job_finish_and_invalidate(u->meta.job, true);
else if (ns != UNIT_ACTIVATING && ns != UNIT_ACTIVE_RELOADING) { else if (ns != UNIT_ACTIVATING && ns != UNIT_ACTIVE_RELOADING) {
unexpected = true; unexpected = true;
job_finish_and_invalidate(u->meta.job, false); job_finish_and_invalidate(u->meta.job, false);
} }
break;
case JOB_STOP:
case JOB_RESTART:
case JOB_TRY_RESTART:
if (ns == UNIT_INACTIVE)
job_finish_and_invalidate(u->meta.job, true);
else if (ns != UNIT_DEACTIVATING) {
unexpected = true;
job_finish_and_invalidate(u->meta.job, false);
}
break;
default:
assert_not_reached("Job type unknown");
} }
break;
case JOB_STOP:
case JOB_RESTART:
case JOB_TRY_RESTART:
if (ns == UNIT_INACTIVE)
job_finish_and_invalidate(u->meta.job, true);
else if (u->meta.job->state == JOB_RUNNING && ns != UNIT_DEACTIVATING) {
unexpected = true;
job_finish_and_invalidate(u->meta.job, false);
}
break;
default:
assert_not_reached("Job type unknown");
} }
} }