mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-21 18:06:50 +00:00
base/child.h: remove Nonexistent_id_space exception
This exception got introduced as a mere convenience for implementers of 'Child_policy' but required a special case in the base library. Following the goal of eliminating exceptions from the base system, this patch removes it by making a server_id_space mandatory. Issue #5245
This commit is contained in:
parent
8b0a16d750
commit
ef385696f6
@ -162,14 +162,10 @@ struct Genode::Child_policy
|
||||
*/
|
||||
virtual void init(Pd_session &, Capability<Pd_session>) { }
|
||||
|
||||
class Nonexistent_id_space : Exception { };
|
||||
|
||||
/**
|
||||
* ID space for sessions provided by the child
|
||||
*
|
||||
* \throw Nonexistent_id_space
|
||||
*/
|
||||
virtual Id_space<Parent::Server> &server_id_space() { throw Nonexistent_id_space(); }
|
||||
virtual Id_space<Parent::Server> &server_id_space() = 0;
|
||||
|
||||
/**
|
||||
* Notification hook invoked each time a session state is modified
|
||||
|
@ -121,6 +121,8 @@ class Core_child : public Child_policy
|
||||
Cap_quota const _cap_quota;
|
||||
Ram_quota const _ram_quota;
|
||||
|
||||
Id_space<Parent::Server> _server_ids { };
|
||||
|
||||
Child _child;
|
||||
|
||||
public:
|
||||
@ -183,6 +185,8 @@ class Core_child : public Child_policy
|
||||
Pd_session_capability ref_pd_cap() const override { return _core_pd_cap; }
|
||||
|
||||
size_t session_alloc_batch_size() const override { return 128; }
|
||||
|
||||
Id_space<Parent::Server> &server_id_space() override { return _server_ids; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -506,7 +506,6 @@ void Child::session_closed(Session_state &session)
|
||||
|
||||
void Child::session_response(Server::Id id, Session_response response)
|
||||
{
|
||||
try {
|
||||
_policy.server_id_space().apply<Session_state>(id, [&] (Session_state &session) {
|
||||
|
||||
switch (response) {
|
||||
@ -591,14 +590,11 @@ void Child::session_response(Server::Id id, Session_response response)
|
||||
[&] /* missing ID */ {
|
||||
warning("unexpected session response for unknown session");
|
||||
});
|
||||
}
|
||||
catch (Child_policy::Nonexistent_id_space) { }
|
||||
}
|
||||
|
||||
|
||||
void Child::deliver_session_cap(Server::Id id, Session_capability cap)
|
||||
{
|
||||
try {
|
||||
_policy.server_id_space().apply<Session_state>(id, [&] (Session_state &session) {
|
||||
|
||||
/* ignore responses after 'close_all_sessions' of the client */
|
||||
@ -631,8 +627,6 @@ void Child::deliver_session_cap(Server::Id id, Session_capability cap)
|
||||
session.ready_callback->session_ready(session);
|
||||
},
|
||||
[&] /* missing ID */ { });
|
||||
}
|
||||
catch (Child_policy::Nonexistent_id_space) { }
|
||||
}
|
||||
|
||||
|
||||
@ -866,11 +860,8 @@ void Child::close_all_sessions()
|
||||
* with the server. So the added complexity of reverting the session quotas
|
||||
* would be to no benefit.
|
||||
*/
|
||||
try {
|
||||
auto lambda = [&] (Session_state &s) { _revert_quota_and_destroy(s); };
|
||||
while (_policy.server_id_space().apply_any<Session_state>(lambda));
|
||||
}
|
||||
catch (Child_policy::Nonexistent_id_space) { }
|
||||
|
||||
/*
|
||||
* Issue close requests to the providers of the environment sessions,
|
||||
|
@ -174,6 +174,7 @@ class Test_child_policy : public Child_policy
|
||||
|
||||
Env &_env;
|
||||
Parent_services &_parent_services;
|
||||
Id_space<Parent::Server> _server_ids { };
|
||||
Signal_context_capability const _fault_handler_sigh;
|
||||
Signal_context_capability const _fault_handler_stack_sigh;
|
||||
|
||||
@ -239,6 +240,8 @@ class Test_child_policy : public Child_policy
|
||||
.label = label,
|
||||
.diag = diag };
|
||||
}
|
||||
|
||||
Id_space<Parent::Server> &server_id_space() override { return _server_ids; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -428,6 +428,8 @@ struct Libc::Forked_child : Child_policy, Child_ready
|
||||
Local_clone_service _local_clone_service;
|
||||
Local_rom_service _config_rom_service;
|
||||
|
||||
Id_space<Parent::Server> _server_ids { };
|
||||
|
||||
pid_t pid() const { return _pid; }
|
||||
|
||||
bool running() const { return _state == State::RUNNING; }
|
||||
@ -539,6 +541,8 @@ struct Libc::Forked_child : Child_policy, Child_ready
|
||||
Signal_transmitter(_exit_handler).submit();
|
||||
}
|
||||
|
||||
Id_space<Parent::Server> &server_id_space() override { return _server_ids; }
|
||||
|
||||
Child _child;
|
||||
|
||||
Forked_child(Env &env,
|
||||
|
@ -70,6 +70,8 @@ struct Sequence::Child : Genode::Child_policy
|
||||
|
||||
Registry<Parent_service> _parent_services { };
|
||||
|
||||
Id_space<Parent::Server> _server_ids { };
|
||||
|
||||
/* queue a child reload from the async Parent interface */
|
||||
Signal_transmitter _exit_transmitter;
|
||||
|
||||
@ -205,6 +207,8 @@ struct Sequence::Child : Genode::Child_policy
|
||||
ref_pd().transfer_quota(pd_cap, Cap_quota{_env.pd().avail_caps().value >> 1});
|
||||
ref_pd().transfer_quota(pd_cap, Ram_quota{_env.pd().avail_ram().value >> 1});
|
||||
}
|
||||
|
||||
Id_space<Parent::Server> &server_id_space() override { return _server_ids; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -57,6 +57,8 @@ class Shim::Main : public Child_policy
|
||||
|
||||
Parent_services _parent_services { };
|
||||
|
||||
Id_space<Parent::Server> _server_ids { };
|
||||
|
||||
Child _child { _env.rm(), _env.ep().rpc_ep(), *this };
|
||||
|
||||
Service &_matching_service(Service::Name const &name)
|
||||
@ -125,6 +127,8 @@ class Shim::Main : public Child_policy
|
||||
label.length()),
|
||||
.diag = diag };
|
||||
}
|
||||
|
||||
Id_space<Parent::Server> &server_id_space() override { return _server_ids; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -37,6 +37,8 @@ class Bomb_child : public Child_policy
|
||||
|
||||
Registry<Registered<Parent_service> > &_parent_services;
|
||||
|
||||
Id_space<Parent::Server> _server_ids { };
|
||||
|
||||
Child_policy_dynamic_rom_file _config_policy { _env.rm(), "config", _env.ep().rpc_ep(), &_env.ram() };
|
||||
|
||||
Child _child { _env.rm(), _env.ep().rpc_ep(), *this };
|
||||
@ -108,6 +110,8 @@ class Bomb_child : public Child_policy
|
||||
.label = label,
|
||||
.diag = diag };
|
||||
}
|
||||
|
||||
Id_space<Parent::Server> &server_id_space() override { return _server_ids; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -75,6 +75,7 @@ class Test_child : public Genode::Child_policy
|
||||
Parent_service _pd_service { _env, Pd_session::service_name() };
|
||||
Parent_service _log_service { _env, Log_session::service_name() };
|
||||
Parent_service _rom_service { _env, Rom_session::service_name() };
|
||||
Id_space<Parent::Server> _server_ids { };
|
||||
Child _child;
|
||||
|
||||
public:
|
||||
@ -134,6 +135,8 @@ class Test_child : public Genode::Child_policy
|
||||
|
||||
throw Service_denied();
|
||||
}
|
||||
|
||||
Id_space<Parent::Server> &server_id_space() override { return _server_ids; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -288,6 +288,8 @@ class Test::Parent
|
||||
Ram_quota const _ram_quota { 10*1024*1024 };
|
||||
Binary_name const _binary_name { "test-resource_yield" };
|
||||
|
||||
Id_space<Genode::Parent::Server> _server_ids { };
|
||||
|
||||
/*
|
||||
* Config ROM service
|
||||
*/
|
||||
@ -353,6 +355,8 @@ class Test::Parent
|
||||
|
||||
return route(*service_ptr);
|
||||
}
|
||||
|
||||
Id_space<Genode::Parent::Server> &server_id_space() override { return _server_ids; }
|
||||
};
|
||||
|
||||
Policy _policy { *this, _env };
|
||||
|
Loading…
x
Reference in New Issue
Block a user