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.
This commit is contained in:
Lennart Poettering
2023-10-06 11:49:38 +02:00
parent abef4a7b3c
commit 7dce9ead5d
3 changed files with 5 additions and 3 deletions
+1 -1
View 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)
+4 -1
View 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);
-1
View 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"