From e17811fb7ab9bd3c36ecb341fb8ad1d9570bb53c Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 17 Feb 2017 10:53:59 +0100 Subject: [PATCH] cli_monitor: API transition Issue #1987 --- .../gems/src/app/launcher/subsystem_manager.h | 2 +- repos/os/include/cli_monitor/child.h | 20 +++++++++++++++---- repos/os/src/app/cli_monitor/child.h | 2 ++ repos/os/src/app/cli_monitor/start_command.h | 4 ++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/repos/gems/src/app/launcher/subsystem_manager.h b/repos/gems/src/app/launcher/subsystem_manager.h index 337c9d212b..90a68c56c2 100644 --- a/repos/gems/src/app/launcher/subsystem_manager.h +++ b/repos/gems/src/app/launcher/subsystem_manager.h @@ -175,7 +175,7 @@ class Launcher::Subsystem_manager try { Child *child = new (_heap) - Child(_ram, label, binary_name.string(), + Child(_ram, _heap, label, binary_name.string(), _env.pd(), _env.ram(), _env.ram_session_cap(), diff --git a/repos/os/include/cli_monitor/child.h b/repos/os/include/cli_monitor/child.h index 175fb03bea..b6f8972651 100644 --- a/repos/os/include/cli_monitor/child.h +++ b/repos/os/include/cli_monitor/child.h @@ -45,12 +45,13 @@ class Cli_monitor::Child_base : public Genode::Child_policy typedef Genode::size_t size_t; typedef Genode::Registered Parent_service; - typedef Genode::Registry Parent_services; private: Ram &_ram; + Genode::Allocator &_alloc; + Genode::Session_label const _label; Binary_name const _binary_name; @@ -60,7 +61,15 @@ class Cli_monitor::Child_base : public Genode::Child_policy size_t _ram_quota; size_t _ram_limit; - Parent_services _parent_services; + struct Parent_services : Genode::Registry + { + Genode::Allocator &_alloc; + Parent_services(Genode::Allocator &alloc) : _alloc(alloc) { } + ~Parent_services() + { + for_each([&] (Parent_service &s) { Genode::destroy(_alloc, &s); }); + } + } _parent_services { _alloc }; enum { ENTRYPOINT_STACK_SIZE = 12*1024 }; Genode::Rpc_entrypoint _entrypoint; @@ -94,8 +103,11 @@ class Cli_monitor::Child_base : public Genode::Child_policy * \param ref_ram used as reference account for the child'd RAM * session and for allocating the backing store * for the child's configuration + * \param alloc allocator used to fill parent-service registry + * on demand */ Child_base(Ram &ram, + Genode::Allocator &alloc, Name const &label, Binary_name const &binary_name, Genode::Pd_session &pd_session, @@ -107,7 +119,7 @@ class Cli_monitor::Child_base : public Genode::Child_policy Genode::Signal_context_capability yield_response_sig_cap, Genode::Signal_context_capability exit_sig_cap) : - _ram(ram), + _ram(ram), _alloc(alloc), _label(label), _binary_name(binary_name), _ref_ram_cap(ref_ram_cap), _ref_ram(ref_ram), _ram_quota(ram_quota), _ram_limit(ram_limit), @@ -289,7 +301,7 @@ class Cli_monitor::Child_base : public Genode::Child_policy if (service) return *service; - return *new (Genode::env()->heap()) Parent_service(_parent_services, name); + return *new (_alloc) Parent_service(_parent_services, name); } void yield_response() diff --git a/repos/os/src/app/cli_monitor/child.h b/repos/os/src/app/cli_monitor/child.h index 770774e4d3..a2e3a8c59b 100644 --- a/repos/os/src/app/cli_monitor/child.h +++ b/repos/os/src/app/cli_monitor/child.h @@ -28,6 +28,7 @@ struct Cli_monitor::Child : Child_base, List::Element Argument argument; Child(Ram &ram, + Genode::Allocator &alloc, Name const &label, Binary_name const &binary, Genode::Pd_session &pd_session, @@ -40,6 +41,7 @@ struct Cli_monitor::Child : Child_base, List::Element Genode::Signal_context_capability exit_sig_cap) : Child_base(ram, + alloc, label, binary, pd_session, diff --git a/repos/os/src/app/cli_monitor/start_command.h b/repos/os/src/app/cli_monitor/start_command.h index 73a33f4969..271db9662e 100644 --- a/repos/os/src/app/cli_monitor/start_command.h +++ b/repos/os/src/app/cli_monitor/start_command.h @@ -113,8 +113,8 @@ class Cli_monitor::Start_command : public Command Child *child = 0; try { child = new (_alloc) - Child(_ram, label, binary_name, _pd, _ref_ram, _ref_ram_cap, - _local_rm, ram, ram_limit, + Child(_ram, _alloc, label, binary_name, _pd, _ref_ram, + _ref_ram_cap, _local_rm, ram, ram_limit, _yield_response_sigh_cap, _exit_sig_cap); } catch (Genode::Parent::Service_denied) {