mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-04 08:30:54 +00:00
root/component.h: POLICY::release on exception
This patch ensures that the POLICY::release is called whenever the session creation aborted with an exception. In the original version, an exception like 'Quota_exceeded' caused a single-session root interface to deny subsequent session requests.
This commit is contained in:
parent
8b4afe95c1
commit
dfc4c58782
@ -122,6 +122,18 @@ class Genode::Root_component : public Rpc_object<Typed_root<SESSION_TYPE> >,
|
|||||||
{
|
{
|
||||||
POLICY::aquire(args.string());
|
POLICY::aquire(args.string());
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Guard to ensure that 'release' is called whenever the scope
|
||||||
|
* is left with an exception.
|
||||||
|
*/
|
||||||
|
struct Guard
|
||||||
|
{
|
||||||
|
bool ack = false;
|
||||||
|
Root_component &root;
|
||||||
|
Guard(Root_component &root) : root(root) { }
|
||||||
|
~Guard() { if (!ack) root.release(); }
|
||||||
|
} aquire_guard { *this };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to decrease 'ram_quota' by
|
* We need to decrease 'ram_quota' by
|
||||||
* the size of the session object.
|
* the size of the session object.
|
||||||
@ -163,6 +175,7 @@ class Genode::Root_component : public Rpc_object<Typed_root<SESSION_TYPE> >,
|
|||||||
|
|
||||||
_ep->manage(s);
|
_ep->manage(s);
|
||||||
|
|
||||||
|
aquire_guard.ack = true;
|
||||||
return *s;
|
return *s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user