From dfc4c58782262f8bec2bb024e46e462dc73aada1 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 21 Feb 2017 15:17:41 +0100 Subject: [PATCH] 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. --- repos/base/include/root/component.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/repos/base/include/root/component.h b/repos/base/include/root/component.h index 81ef7d2d4..35698b90e 100644 --- a/repos/base/include/root/component.h +++ b/repos/base/include/root/component.h @@ -122,6 +122,18 @@ class Genode::Root_component : public Rpc_object >, { 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 * the size of the session object. @@ -163,6 +175,7 @@ class Genode::Root_component : public Rpc_object >, _ep->manage(s); + aquire_guard.ack = true; return *s; }