base: handle cap depletion during session upgrade

When the own cap quota of a client does not suffice for a cap upgrade of
an existing session to a server, the client must issue a cap-resource
request to the parent. This logic was already in place for RAM quota but
was missing for cap quota.

Issue #4072
This commit is contained in:
Norman Feske 2021-04-09 18:07:15 +02:00
parent 2084404aba
commit 4e714d3f3a

View File

@ -144,14 +144,25 @@ class Genode::Expanding_parent_client : public Parent_client
* immediately. The second upgrade attempt may fail too if the * immediately. The second upgrade attempt may fail too if the
* parent handles the resource request asynchronously. In this * parent handles the resource request asynchronously. In this
* case, we escalate the problem to caller by propagating the * case, we escalate the problem to caller by propagating the
* 'Out_of_ram' exception. Now, it is the job of the caller to * 'Out_of_ram' or 'Out_of_caps' exception. Now, it is the job of
* issue (and respond to) a resource request. * the caller to issue (and respond to) a resource request.
*/ */
enum { NUM_ATTEMPTS = 2 }; Session::Resources const amount = session_resources_from_args(args.string());
using Arg = String<64>;
return retry<Out_of_ram>( return retry<Out_of_ram>(
[&] () { return Parent_client::upgrade(id, args); }, [&] () {
[&] () { resource_request(Resource_args(args.string())); }, return retry<Out_of_caps>(
NUM_ATTEMPTS); [&] () { return Parent_client::upgrade(id, args); },
[&] () {
Arg cap_arg("cap_quota=", amount.cap_quota);
resource_request(Resource_args(cap_arg.string()));
});
},
[&] () {
Arg ram_arg("ram_quota=", amount.ram_quota);
resource_request(Resource_args(ram_arg.string()));
});
} }
void resource_avail_sigh(Signal_context_capability sigh) override void resource_avail_sigh(Signal_context_capability sigh) override