From 034de3b1b1487ad9412fff59d3371ddca82f4dd8 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 4 Sep 2024 13:46:52 +0200 Subject: [PATCH] base/connection.h: allow customized cap-quota arg By default, a 'Connection' donates an amount of caps as declared in SESSION_TYPE::CAP_QUOTA to the server at session-creation time. In some situations, however, a client may deliberately want to donate a larger amount. For example, when opening a GUI session at the wm, the total amount of needed caps is the sum of those consumed by the wm plus those consumed by nitpicker. Using this knowledge, the Gui::Connection may specify a sufficient amount to avoid iterative session-creation retries. The new 'Connection' constructor accommodates this use case by accepting an explicit 'cap_quota' argument. Issue #5340 --- repos/base/include/base/connection.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/repos/base/include/base/connection.h b/repos/base/include/base/connection.h index 1798d84906..9e6c915d5e 100644 --- a/repos/base/include/base/connection.h +++ b/repos/base/include/base/connection.h @@ -107,13 +107,14 @@ class Genode::Connection : public Connection_base Client_id const &id, Session_label const &label, Ram_quota const &ram_quota, + Cap_quota const &cap_quota, Affinity const &affinity, Args const &args) { /* supplement session quotas and label as session arguments */ Args const complete_args("label=\"", label, "\", " "ram_quota=", ram_quota, ", " - "cap_quota=", unsigned(SESSION_TYPE::CAP_QUOTA), ", ", + "cap_quota=", cap_quota, ", ", args); if (complete_args.length() == Args::capacity()) @@ -138,12 +139,26 @@ class Genode::Connection : public Connection_base Connection(Env &env, Session_label const &label, Ram_quota const &ram_quota, + Cap_quota const &cap_quota, Affinity const &affinity, Args const &args) : Connection_base(env), _cap(_request(env, _id_space_element.id(), - label, ram_quota, affinity, args)) + label, ram_quota, cap_quota, affinity, args)) + { } + + /** + * Constructor using the cap quota declared in as SESSION_TYPE::CAP_QUOTA + */ + Connection(Env &env, + Session_label const &label, + Ram_quota const &ram_quota, + Affinity const &affinity, + Args const &args) + : + Connection(env, label, ram_quota, Cap_quota { unsigned(SESSION_TYPE::CAP_QUOTA) }, + affinity, args) { } /**