diff --git a/repos/base-linux/src/lib/base/platform.cc b/repos/base-linux/src/lib/base/platform.cc index 3f72a96351..7d08b6b469 100644 --- a/repos/base-linux/src/lib/base/platform.cc +++ b/repos/base-linux/src/lib/base/platform.cc @@ -77,25 +77,20 @@ Session_capability Local_parent::session(Parent::Client::Id id, Parent::Close_result Local_parent::close(Client::Id id) { - auto close_local_fn = [&] (Local_session &local_session) - { - Capability rm = - static_cap_cast(local_session.local_session_cap()); - destroy(_alloc, Local_capability::deref(rm)); - }; - /* * Local RM sessions are present in the '_local_sessions_id_space'. If the * apply succeeds, 'id' referred to the local session. Otherwise, we * forward the request to the parent. */ - try { - _local_sessions_id_space.apply(id, close_local_fn); - return CLOSE_DONE; - } - catch (Id_space::Unknown_id) { } - - return Parent_client::close(id); + return _local_sessions_id_space.apply(id, + [&] (Local_session &local_session) -> Parent::Close_result { + Capability rm = + static_cap_cast(local_session.local_session_cap()); + destroy(_alloc, Local_capability::deref(rm)); + return CLOSE_DONE; + }, + [&] /* missing */ { + return Parent_client::close(id); }); } diff --git a/repos/base-nova/src/lib/base/vm.cc b/repos/base-nova/src/lib/base/vm.cc index 8d1709e78b..d67ab14311 100644 --- a/repos/base-nova/src/lib/base/vm.cc +++ b/repos/base-nova/src/lib/base/vm.cc @@ -656,9 +656,8 @@ void Nova_vcpu::_exit_entry(addr_t badge) Vcpu_space::Id const vcpu_id { Badge(badge).vcpu_id() }; - try { - _vcpu_space().apply(vcpu_id, [&] (Nova_vcpu &vcpu) - { + _vcpu_space().apply(vcpu_id, + [&] (Nova_vcpu &vcpu) { vcpu._handle_exit(utcb); vcpu._last_resume = vcpu._resume; @@ -667,15 +666,13 @@ void Nova_vcpu::_exit_entry(addr_t badge) } else { nova_reply(myself, utcb, vcpu._sm_sel()); } + }, + [&] /* missing */ { + /* somebody called us directly ? ... ignore/deny */ + utcb.items = 0; + utcb.mtd = 0; + nova_reply(myself, utcb); }); - - } catch (Vcpu_space::Unknown_id &) { - - /* somebody called us directly ? ... ignore/deny */ - utcb.items = 0; - utcb.mtd = 0; - nova_reply(myself, utcb); - } } diff --git a/repos/base/src/lib/base/child.cc b/repos/base/src/lib/base/child.cc index 05980423c5..ec476d5726 100644 --- a/repos/base/src/lib/base/child.cc +++ b/repos/base/src/lib/base/child.cc @@ -125,11 +125,9 @@ create_session(Child_policy::Name const &child_name, Service &service, error(child_name, " requested conflicting session ID ", id, " " "(service=", service.name(), " args=", args, ")"); - try { - id_space.apply(id, [&] (Session_state &session) { - error("existing session: ", session); }); - } - catch (Id_space::Unknown_id) { } + id_space.apply(id, + [&] (Session_state &session) { error("existing session: ", session); }, + [&] /* missing */ { }); } throw Service_denied(); } @@ -264,48 +262,46 @@ Session_capability Child::session(Parent::Client::Id id, Session_capability Child::session_cap(Client::Id id) { - Session_capability cap; + return _id_space.apply(id, - auto lamda = [&] (Session_state &session) { + [&] (Session_state &session) -> Session_capability { - if (session.phase == Session_state::SERVICE_DENIED - || session.phase == Session_state::INSUFFICIENT_RAM_QUOTA - || session.phase == Session_state::INSUFFICIENT_CAP_QUOTA) { + if (session.phase == Session_state::SERVICE_DENIED + || session.phase == Session_state::INSUFFICIENT_RAM_QUOTA + || session.phase == Session_state::INSUFFICIENT_CAP_QUOTA) { - Session_state::Phase const phase = session.phase; + Session_state::Phase const phase = session.phase; - /* - * Implicity discard the session request when delivering an - * exception because the exception will trigger the deallocation - * of the session ID at the child anyway. - */ - _revert_quota_and_destroy(session); + /* + * Implicity discard the session request when delivering an + * exception because the exception will trigger the deallocation + * of the session ID at the child anyway. + */ + _revert_quota_and_destroy(session); - switch (phase) { - case Session_state::SERVICE_DENIED: throw Service_denied(); - case Session_state::INSUFFICIENT_RAM_QUOTA: throw Insufficient_ram_quota(); - case Session_state::INSUFFICIENT_CAP_QUOTA: throw Insufficient_cap_quota(); - default: break; + switch (phase) { + case Session_state::SERVICE_DENIED: throw Service_denied(); + case Session_state::INSUFFICIENT_RAM_QUOTA: throw Insufficient_ram_quota(); + case Session_state::INSUFFICIENT_CAP_QUOTA: throw Insufficient_cap_quota(); + default: break; + } } + + if (!session.alive()) + warning(_policy.name(), ": attempt to request cap for unavailable session: ", session); + + if (session.cap.valid()) + session.phase = Session_state::CAP_HANDED_OUT; + + _policy.session_state_changed(); + + return session.cap; + }, + [&] /* missing */ { + warning(_policy.name(), " requested session cap for unknown ID"); + return Session_capability(); } - - if (!session.alive()) - warning(_policy.name(), ": attempt to request cap for unavailable session: ", session); - - if (session.cap.valid()) - session.phase = Session_state::CAP_HANDED_OUT; - - cap = session.cap; - }; - - try { - _id_space.apply(id, lamda); } - - catch (Id_space::Unknown_id) { - warning(_policy.name(), " requested session cap for unknown ID"); } - - _policy.session_state_changed(); - return cap; + ); } @@ -379,8 +375,7 @@ Parent::Upgrade_result Child::upgrade(Client::Id id, Parent::Upgrade_args const session.service().wakeup(); }; - try { _id_space.apply(id, upgrade_session); } - catch (Id_space::Unknown_id) { } + _id_space.apply(id, upgrade_session, [&] /* missing */ { }); _policy.session_state_changed(); return result; @@ -479,13 +474,9 @@ Child::Close_result Child::close(Client::Id id) if (Parent::Env::session_id(id)) return CLOSE_DONE; - try { - Close_result result = CLOSE_PENDING; - auto lamda = [&] (Session_state &session) { result = _close(session); }; - _id_space.apply(id, lamda); - return result; - } - catch (Id_space::Unknown_id) { return CLOSE_DONE; } + return _id_space.apply(id, + [&] (Session_state &session) -> Close_result { return _close(session); }, + [&] /* missing */ { return CLOSE_DONE; }); } @@ -596,11 +587,12 @@ void Child::session_response(Server::Id id, Session_response response) } break; } + }, + [&] /* missing ID */ { + warning("unexpected session response for unknown session"); }); } catch (Child_policy::Nonexistent_id_space) { } - catch (Id_space::Unknown_id) { - warning("unexpected session response for unknown session"); } } @@ -637,10 +629,10 @@ void Child::deliver_session_cap(Server::Id id, Session_capability cap) if (session.ready_callback) session.ready_callback->session_ready(session); - }); + }, + [&] /* missing ID */ { }); } catch (Child_policy::Nonexistent_id_space) { } - catch (Id_space::Unknown_id) { } } @@ -781,10 +773,9 @@ void Child::_try_construct_env_dependent_members() void Child::_discard_env_session(Id_space::Id id) { - auto discard_id_fn = [&] (Session_state &s) { s.discard_id_at_client(); }; - - try { _id_space.apply(id, discard_id_fn); } - catch (Id_space::Unknown_id) { } + _id_space.apply(id, + [&] (Session_state &s) { s.discard_id_at_client(); }, + [&] /* missing */ { }); }