core: change internal error code for masked units from EBADR to ESHUTDOWN
This commit changes the mapping of the BUS_ERROR_UNIT_MASKED error to ESHUTDOWN. This error is used whenever the
transaction engine is asked to operate on a masked unit. ESHUTDOWN is what is used for the similar case when the unit
file enable/disable logic hits a masked unit file, hence is a natural candidate to be used here too.
Background: before this patch both "job type not applicable" and "unit masked" where mapped to EBADR, which
transaction_add_job_and_dependencies() then checked for. It actually wanted to check exclusively for the former error
condition, not the latter but due to the same mapping this failed to work.
This patch semi-undoes an accidental change made in caffa4ef70
, however restores the
error number to ESHUTDOWN instead of the original ENOSYS (for the reasons indicated above).
To make this easier to grok for the future, I added comments to explaining which error conditions are checked for.
Fixes: #2315
This commit is contained in:
parent
bae687d885
commit
114400dfb3
|
@ -912,7 +912,7 @@ int transaction_add_job_and_dependencies(
|
|||
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES], i) {
|
||||
r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, false, false, ignore_order, e);
|
||||
if (r < 0) {
|
||||
if (r != -EBADR)
|
||||
if (r != -EBADR) /* job type not applicable */
|
||||
goto fail;
|
||||
|
||||
sd_bus_error_free(e);
|
||||
|
@ -922,7 +922,7 @@ int transaction_add_job_and_dependencies(
|
|||
SET_FOREACH(dep, ret->unit->dependencies[UNIT_BINDS_TO], i) {
|
||||
r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, false, false, ignore_order, e);
|
||||
if (r < 0) {
|
||||
if (r != -EBADR)
|
||||
if (r != -EBADR) /* job type not applicable */
|
||||
goto fail;
|
||||
|
||||
sd_bus_error_free(e);
|
||||
|
@ -932,9 +932,9 @@ int transaction_add_job_and_dependencies(
|
|||
SET_FOREACH(dep, ret->unit->dependencies[UNIT_WANTS], i) {
|
||||
r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, false, false, false, ignore_order, e);
|
||||
if (r < 0) {
|
||||
/* unit masked and unit not found are not considered as errors. */
|
||||
/* unit masked, job type not applicable and unit not found are not considered as errors. */
|
||||
log_unit_full(dep,
|
||||
r == -EBADR || r == -ENOENT ? LOG_DEBUG : LOG_WARNING,
|
||||
r == -ESHUTDOWN || r == -EBADR || r == -ENOENT ? LOG_DEBUG : LOG_WARNING,
|
||||
r, "Cannot add dependency job, ignoring: %s",
|
||||
bus_error_message(e, r));
|
||||
sd_bus_error_free(e);
|
||||
|
@ -944,7 +944,7 @@ int transaction_add_job_and_dependencies(
|
|||
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE], i) {
|
||||
r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, true, false, false, ignore_order, e);
|
||||
if (r < 0) {
|
||||
if (r != -EBADR)
|
||||
if (r != -EBADR) /* job type not applicable */
|
||||
goto fail;
|
||||
|
||||
sd_bus_error_free(e);
|
||||
|
@ -954,7 +954,7 @@ int transaction_add_job_and_dependencies(
|
|||
SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTS], i) {
|
||||
r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, true, true, false, ignore_order, e);
|
||||
if (r < 0) {
|
||||
if (r != -EBADR)
|
||||
if (r != -EBADR) /* job type not applicable */
|
||||
goto fail;
|
||||
|
||||
sd_bus_error_free(e);
|
||||
|
@ -999,7 +999,7 @@ int transaction_add_job_and_dependencies(
|
|||
|
||||
r = transaction_add_job_and_dependencies(tr, nt, dep, ret, true, false, false, ignore_order, e);
|
||||
if (r < 0) {
|
||||
if (r != -EBADR)
|
||||
if (r != -EBADR) /* job type not applicable */
|
||||
goto fail;
|
||||
|
||||
sd_bus_error_free(e);
|
||||
|
|
|
@ -39,7 +39,7 @@ BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_common_errors[] = {
|
|||
SD_BUS_ERROR_MAP(BUS_ERROR_TRANSACTION_JOBS_CONFLICTING, EDEADLK),
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC, EDEADLK),
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_TRANSACTION_IS_DESTRUCTIVE, EDEADLK),
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_UNIT_MASKED, EBADR),
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_UNIT_MASKED, ESHUTDOWN),
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_JOB_TYPE_NOT_APPLICABLE, EBADR),
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_NO_ISOLATION, EPERM),
|
||||
SD_BUS_ERROR_MAP(BUS_ERROR_SHUTTING_DOWN, ECANCELED),
|
||||
|
|
Loading…
Reference in a new issue