From: Mike Yuan Date: Tue, 11 Jun 2024 17:09:05 +0000 (+0200) Subject: core/dbus-unit: add an explicit bus error when unit is frozen by parent X-Git-Tag: v257-rc1~888^2~3 X-Git-Url: http://git-history.diyao.me/?a=commitdiff_plain;h=6798fa11d2888f95907028d7bc43defa05102c74;p=systemd%2F.git core/dbus-unit: add an explicit bus error when unit is frozen by parent While at it, use more accurate errno (EDEADLK) instead of ECHILD. --- diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index a9ae81aed5..a51d1da3df 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -755,8 +755,8 @@ static int bus_unit_method_freezer_generic(sd_bus_message *message, void *userda return sd_bus_error_set(error, BUS_ERROR_UNIT_INACTIVE, "Unit is not active"); if (r == -EALREADY) return sd_bus_error_set(error, BUS_ERROR_UNIT_BUSY, "Previously requested freezer operation for unit is still in progress"); - if (r == -ECHILD) - return sd_bus_error_set(error, SD_BUS_ERROR_FAILED, "Unit is frozen by a parent slice"); + if (r == -EDEADLK) + return sd_bus_error_set(error, BUS_ERROR_FROZEN_BY_PARENT, "Unit is frozen by a parent slice"); if (r < 0) return r; diff --git a/src/core/unit.c b/src/core/unit.c index 2ef2a1fbe8..c281a29391 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -6308,7 +6308,7 @@ int unit_freezer_action(Unit *u, FreezerAction action) { if (action == FREEZER_THAW && u->freezer_state == FREEZER_THAWING) return -EALREADY; if (action == FREEZER_THAW && IN_SET(u->freezer_state, FREEZER_FREEZING_BY_PARENT, FREEZER_FROZEN_BY_PARENT)) - return -ECHILD; + return -EDEADLK; r = UNIT_VTABLE(u)->freezer_action(u, action); if (r <= 0) diff --git a/src/libsystemd/sd-bus/bus-common-errors.c b/src/libsystemd/sd-bus/bus-common-errors.c index a4b54f6619..5b18241f00 100644 --- a/src/libsystemd/sd-bus/bus-common-errors.c +++ b/src/libsystemd/sd-bus/bus-common-errors.c @@ -34,6 +34,7 @@ BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_common_errors[] = { SD_BUS_ERROR_MAP(BUS_ERROR_DISK_FULL, ENOSPC), SD_BUS_ERROR_MAP(BUS_ERROR_FILE_DESCRIPTOR_STORE_DISABLED, EHOSTDOWN), + SD_BUS_ERROR_MAP(BUS_ERROR_FROZEN_BY_PARENT, EDEADLK), SD_BUS_ERROR_MAP(BUS_ERROR_NO_SUCH_MACHINE, ENXIO), SD_BUS_ERROR_MAP(BUS_ERROR_NO_SUCH_IMAGE, ENOENT), diff --git a/src/libsystemd/sd-bus/bus-common-errors.h b/src/libsystemd/sd-bus/bus-common-errors.h index 4ef42af7a9..fb1d421168 100644 --- a/src/libsystemd/sd-bus/bus-common-errors.h +++ b/src/libsystemd/sd-bus/bus-common-errors.h @@ -34,6 +34,7 @@ #define BUS_ERROR_FREEZE_CANCELLED "org.freedesktop.systemd1.FreezeCancelled" #define BUS_ERROR_FILE_DESCRIPTOR_STORE_DISABLED \ "org.freedesktop.systemd1.FileDescriptorStoreDisabled" +#define BUS_ERROR_FROZEN_BY_PARENT "org.freedesktop.systemd1.FrozenByParent" #define BUS_ERROR_NO_SUCH_MACHINE "org.freedesktop.machine1.NoSuchMachine" #define BUS_ERROR_NO_SUCH_IMAGE "org.freedesktop.machine1.NoSuchImage"