]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/dbus-unit: add an explicit bus error when unit is frozen by parent
authorMike Yuan <me@yhndnzj.com>
Tue, 11 Jun 2024 17:09:05 +0000 (19:09 +0200)
committerMike Yuan <me@yhndnzj.com>
Wed, 17 Jul 2024 16:14:32 +0000 (18:14 +0200)
While at it, use more accurate errno (EDEADLK) instead of ECHILD.

src/core/dbus-unit.c
src/core/unit.c
src/libsystemd/sd-bus/bus-common-errors.c
src/libsystemd/sd-bus/bus-common-errors.h

index a9ae81aed501130b137ff48e9bd2c5b998bc5457..a51d1da3df98c9876ea779ed95490da78c62c415 100644 (file)
@@ -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;
 
index 2ef2a1fbe8e1eb71c522b146bec9d6ad56773341..c281a29391df139f04881969e623a5f91a2d448e 100644 (file)
@@ -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)
index a4b54f66196e0bec6a91f2f61bf26f0bb2c15b92..5b18241f00e8a63072d2e50f961c34debc35a9da 100644 (file)
@@ -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),
index 4ef42af7a9f33611fb7fde06a790c0ec38aa1505..fb1d42116810aa36490a47663bae88e12ee127c0 100644 (file)
@@ -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"