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.
This commit is contained in:
Alexander Boettcher 2016-11-18 21:48:03 +01:00 committed by Christian Helmuth
parent 03f0f38567
commit 11b2f30318
2 changed files with 27 additions and 7 deletions

View File

@ -180,7 +180,7 @@ namespace Noux {
* Locally-provided CPU service
*/
typedef Local_service<Cpu_session_component> 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 };

View File

@ -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 &registry)
: _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(); }