job_finish_and_invalidate(u->meta.job, true);
else if (u->meta.job->state == JOB_RUNNING && ns != UNIT_ACTIVATING) {
unexpected = true;
- job_finish_and_invalidate(u->meta.job, false);
+
+ if (UNIT_IS_INACTIVE_OR_MAINTENANCE(ns))
+ job_finish_and_invalidate(u->meta.job, ns != UNIT_MAINTENANCE);
}
break;
job_finish_and_invalidate(u->meta.job, true);
else if (ns != UNIT_ACTIVATING && ns != UNIT_RELOADING) {
unexpected = true;
- job_finish_and_invalidate(u->meta.job, false);
+
+ if (UNIT_IS_INACTIVE_OR_MAINTENANCE(ns))
+ job_finish_and_invalidate(u->meta.job, ns != UNIT_MAINTENANCE);
}
}
case JOB_RESTART:
case JOB_TRY_RESTART:
- if (ns == UNIT_INACTIVE || ns == UNIT_MAINTENANCE)
+ if (UNIT_IS_INACTIVE_OR_MAINTENANCE(ns))
job_finish_and_invalidate(u->meta.job, true);
else if (u->meta.job->state == JOB_RUNNING && ns != UNIT_DEACTIVATING) {
unexpected = true;