From 11b2f303182ca41f4796a2efb12e2ede36f0ea4e Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 18 Nov 2016 21:48:03 +0100 Subject: [PATCH] noux: avoid tons of "no attachment" messages Trace_control dataspace gets destroyed implicitly when the cpu session is closed. Remove the trace control dataspace from the internal noux dataspace registry before cpu session destruction. --- repos/ports/src/noux/child.h | 2 +- repos/ports/src/noux/cpu_session_component.h | 32 ++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/repos/ports/src/noux/child.h b/repos/ports/src/noux/child.h index 0a511fbb9a..2d95217901 100644 --- a/repos/ports/src/noux/child.h +++ b/repos/ports/src/noux/child.h @@ -180,7 +180,7 @@ namespace Noux { * Locally-provided CPU service */ typedef Local_service Cpu_service; - Cpu_session_component _cpu { _ep, _name, false }; + Cpu_session_component _cpu { _ep, _name, false, _ds_registry }; Cpu_service::Single_session_factory _cpu_factory { _cpu }; Cpu_service _cpu_service { _cpu_factory }; diff --git a/repos/ports/src/noux/cpu_session_component.h b/repos/ports/src/noux/cpu_session_component.h index 64d0046aa9..abbaf9971c 100644 --- a/repos/ports/src/noux/cpu_session_component.h +++ b/repos/ports/src/noux/cpu_session_component.h @@ -47,7 +47,9 @@ namespace Noux { enum { MAX_THREADS = 8, MAIN_THREAD_IDX = 0 }; - Thread_capability _threads[MAX_THREADS]; + Thread_capability _threads[MAX_THREADS]; + Dataspace_capability _trace_control; + Dataspace_registry &_registry; public: @@ -63,11 +65,22 @@ namespace Noux { * startup of the main thread. */ Cpu_session_component(Rpc_entrypoint &ep, Child_policy::Name const &label, - bool forked) - : _ep(ep), _forked(forked), _cpu(label.string()) + bool forked, Dataspace_registry ®istry) + : _ep(ep), _forked(forked), _cpu(label.string()), _registry(registry) { _ep.manage(this); } - ~Cpu_session_component() { _ep.dissolve(this); } + ~Cpu_session_component() + { + _ep.dissolve(this); + + if (!_trace_control.valid()) + return; + + auto lambda = [&] (Static_dataspace_info *rdi) { return rdi; }; + Static_dataspace_info *ds_info = _registry.apply(_trace_control, lambda); + if (ds_info) + destroy(env()->heap(), ds_info); + } /** * Explicitly start main thread, only meaningful when @@ -131,8 +144,15 @@ namespace Noux { Affinity::Space affinity_space() const override { return _cpu.affinity_space(); } - Dataspace_capability trace_control() override { - return _cpu.trace_control(); } + Dataspace_capability trace_control() override + { + if (!_trace_control.valid()) { + _trace_control = _cpu.trace_control(); + new (env()->heap()) Static_dataspace_info(_registry, + _trace_control); + } + return _trace_control; + } Quota quota() override { return _cpu.quota(); }