]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
oomd: move SubscriptionTaken Varlink error out of generic Varlink code
authorLennart Poettering <lennart@poettering.net>
Mon, 25 Sep 2023 09:49:38 +0000 (11:49 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 6 Oct 2023 09:49:38 +0000 (11:49 +0200)
This error is a private error returned by PID 1 to oomd. It's internal,
and very specific to the use-case. Hence it should not be part of the
org.varlink.service interface (which isn't really our namespace anyway).

Hence, let's clean this up and move it over to the ManagedOOM varlink
interface of PID, where it belongs.

Since this is a private protocol of our two daemons, and the client
(i.e. oomd) doesn't explicitly test for this error anyway we can just
move it over without ill effects.

src/core/core-varlink.c
src/shared/varlink-io.systemd.ManagedOOM.c
src/shared/varlink.h

index b0b15d242ccd7e07090affe1206d75dd08c45b36..71714e94731176d511451c242ed39662b535de80 100644 (file)
@@ -234,7 +234,7 @@ static int vl_method_subscribe_managed_oom_cgroups(
         /* We only take one subscriber for this method so return an error if there's already an existing one.
          * This shouldn't happen since systemd-oomd is the only client of this method. */
         if (FLAGS_SET(flags, VARLINK_METHOD_MORE) && m->managed_oom_varlink)
-                return varlink_error(link, VARLINK_ERROR_SUBSCRIPTION_TAKEN, NULL);
+                return varlink_error(link, "io.systemd.ManagedOOM.SubscriptionTaken", NULL);
 
         r = build_managed_oom_cgroups_json(m, &v);
         if (r < 0)
index 7cc5721dc2ee85f19784d7ae41fb4d38576f0ea3..d6414b3718ff197f07dd30495ef30bafe5b61063 100644 (file)
@@ -13,8 +13,11 @@ static VARLINK_DEFINE_METHOD(
                 SubscribeManagedOOMCGroups,
                 VARLINK_DEFINE_OUTPUT_BY_TYPE(cgroups, ControlGroup, VARLINK_ARRAY));
 
+static VARLINK_DEFINE_ERROR(SubscriptionTaken);
+
 VARLINK_DEFINE_INTERFACE(
                 io_systemd_ManagedOOM,
                 "io.systemd.ManagedOOM",
                 &vl_method_SubscribeManagedOOMCGroups,
-                &vl_type_ControlGroup);
+                &vl_type_ControlGroup,
+                &vl_error_SubscriptionTaken);
index be4b3289693e8611a8040d22211be94dd629657c..d49a8510f048fa95c92e35d43dce57b8ce40a537 100644 (file)
@@ -200,5 +200,4 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(VarlinkServer *, varlink_server_unref);
 #define VARLINK_ERROR_INVALID_PARAMETER "org.varlink.service.InvalidParameter"
 
 /* These are errors we came up with and squatted the namespace with */
-#define VARLINK_ERROR_SUBSCRIPTION_TAKEN "org.varlink.service.SubscriptionTaken"
 #define VARLINK_ERROR_PERMISSION_DENIED "org.varlink.service.PermissionDenied"