mirror of
https://github.com/systemd/systemd.git
synced 2024-12-26 03:22:00 +03:00
core: make unit_start() return a distinguishable error code in case conditions didn't hold
Ideally we'd even propagate this all the way to the client, by having a separate JobType enum value for this. But it's hard to add this without breaking compat, hence for now let's at least internally propagate this case differently from the case "already on it". This is then used to call job_finish_and_invalidate() slightly differently, with the already= parameter false, as in the failed condition case no message was likely produced so far.
This commit is contained in:
parent
0e2b4a822e
commit
6e64994d69
@ -714,8 +714,10 @@ int job_run_and_invalidate(Job *j) {
|
||||
if (j) {
|
||||
if (r == -EAGAIN)
|
||||
job_set_state(j, JOB_WAITING); /* Hmm, not ready after all, let's return to JOB_WAITING state */
|
||||
else if (r == -EALREADY)
|
||||
else if (r == -EALREADY) /* already being executed */
|
||||
r = job_finish_and_invalidate(j, JOB_DONE, true, true);
|
||||
else if (r == -ECOMM) /* condition failed, but all is good */
|
||||
r = job_finish_and_invalidate(j, JOB_DONE, true, false);
|
||||
else if (r == -EBADR)
|
||||
r = job_finish_and_invalidate(j, JOB_SKIPPED, true, false);
|
||||
else if (r == -ENOEXEC)
|
||||
|
@ -2138,7 +2138,7 @@ static int manager_dispatch_run_queue(sd_event_source *source, void *userdata) {
|
||||
assert(j->installed);
|
||||
assert(j->in_run_queue);
|
||||
|
||||
job_run_and_invalidate(j);
|
||||
(void) job_run_and_invalidate(j);
|
||||
}
|
||||
|
||||
if (m->n_running_jobs > 0)
|
||||
|
@ -1726,7 +1726,7 @@ int unit_start(Unit *u) {
|
||||
if (state != UNIT_ACTIVATING &&
|
||||
!unit_condition_test(u)) {
|
||||
log_unit_debug(u, "Starting requested but condition failed. Not starting unit.");
|
||||
return -EALREADY;
|
||||
return -ECOMM;
|
||||
}
|
||||
|
||||
/* If the asserts failed, fail the entire job */
|
||||
|
Loading…
Reference in New Issue
Block a user