X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fjob.c;h=8ab12cd62410eb3287e4a6c052915108b79fa604;hp=5d4a092345e9aee79d923a3dc44f0c3a64128d6a;hb=e6a3ff9593e88a57390534b8ad3de7a57cafbdb0;hpb=2cf19a7a8f42a313234b716eeefe08bdf77af348 diff --git a/src/job.c b/src/job.c index 5d4a09234..8ab12cd62 100644 --- a/src/job.c +++ b/src/job.c @@ -1,4 +1,4 @@ -/*-*- Mode: C; c-basic-offset: 8 -*-*/ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ /*** This file is part of systemd. @@ -271,7 +271,7 @@ bool job_type_is_redundant(JobType a, UnitActiveState b) { case JOB_STOP: return b == UNIT_INACTIVE || - b == UNIT_MAINTENANCE; + b == UNIT_FAILED; case JOB_VERIFY_ACTIVE: return @@ -417,7 +417,7 @@ int job_run_and_invalidate(Job *j) { case JOB_RESTART: { UnitActiveState t = unit_active_state(j->unit); - if (t == UNIT_INACTIVE || t == UNIT_MAINTENANCE || t == UNIT_ACTIVATING) { + if (t == UNIT_INACTIVE || t == UNIT_FAILED || t == UNIT_ACTIVATING) { j->type = JOB_START; r = unit_start(j->unit); } else @@ -427,7 +427,7 @@ int job_run_and_invalidate(Job *j) { case JOB_TRY_RESTART: { UnitActiveState t = unit_active_state(j->unit); - if (t == UNIT_INACTIVE || t == UNIT_MAINTENANCE || t == UNIT_DEACTIVATING) + if (t == UNIT_INACTIVE || t == UNIT_FAILED || t == UNIT_DEACTIVATING) r = -ENOEXEC; else if (t == UNIT_ACTIVATING) { j->type = JOB_START; @@ -478,14 +478,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 +500,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)) @@ -540,6 +540,8 @@ int job_finish_and_invalidate(Job *j, bool success) { if (other->meta.job) job_add_to_run_queue(other->meta.job); + manager_check_finished(u->meta.manager); + return 0; }