From: Lennart Poettering Date: Mon, 25 Sep 2023 09:49:38 +0000 (+0200) Subject: oomd: move SubscriptionTaken Varlink error out of generic Varlink code X-Git-Tag: v255-rc1~305^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7dce9ead5d92703480afc312d2eb30b441348bf6;p=thirdparty%2Fsystemd.git oomd: move SubscriptionTaken Varlink error out of generic Varlink code 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. --- diff --git a/src/core/core-varlink.c b/src/core/core-varlink.c index b0b15d242cc..71714e94731 100644 --- a/src/core/core-varlink.c +++ b/src/core/core-varlink.c @@ -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) diff --git a/src/shared/varlink-io.systemd.ManagedOOM.c b/src/shared/varlink-io.systemd.ManagedOOM.c index 7cc5721dc2e..d6414b3718f 100644 --- a/src/shared/varlink-io.systemd.ManagedOOM.c +++ b/src/shared/varlink-io.systemd.ManagedOOM.c @@ -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); diff --git a/src/shared/varlink.h b/src/shared/varlink.h index be4b3289693..d49a8510f04 100644 --- a/src/shared/varlink.h +++ b/src/shared/varlink.h @@ -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"