mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-09 04:15:52 +00:00
core: explicitly throw Out_of_metadata
In case there is not enough quota left to create the trace buffer or trace policy dataspace throw Out_of_metadata explicitly instead of rethrowing the Ram_session::Quota_exceeded exception. Now one can catch Trace::Out_of_metadata exception in a client application. In addition fix Allocator_guard::withdraw() checks because this method does not throw any exceptions and a failed withdrawal goes unoticed. Fixes #871.
This commit is contained in:
parent
ca0f677da9
commit
2501cb189e
@ -43,17 +43,17 @@ Policy_id Session_component::alloc_policy(size_t size)
|
||||
|
||||
Policy_id const id(_policy_cnt++);
|
||||
|
||||
try { _md_alloc.withdraw(size); }
|
||||
catch (...) { throw Out_of_metadata(); }
|
||||
if (!_md_alloc.withdraw(size))
|
||||
throw Out_of_metadata();
|
||||
|
||||
try {
|
||||
Ram_dataspace_capability ds = _ram.alloc(size);
|
||||
|
||||
_policies.insert(*this, id, _policies_slab, ds, size);
|
||||
} catch (...) {
|
||||
/* revert withdrawal or quota and re-throw exception */
|
||||
/* revert withdrawal or quota */
|
||||
_md_alloc.upgrade(size);
|
||||
throw;
|
||||
throw Out_of_metadata();
|
||||
}
|
||||
|
||||
return id;
|
||||
@ -82,17 +82,17 @@ void Session_component::trace(Subject_id subject_id, Policy_id policy_id,
|
||||
* Account RAM needed for trace buffer and policy buffer to the trace
|
||||
* session.
|
||||
*/
|
||||
try { _md_alloc.withdraw(required_ram); }
|
||||
catch (...) { throw Out_of_metadata(); }
|
||||
if (!_md_alloc.withdraw(required_ram))
|
||||
throw Out_of_metadata();
|
||||
|
||||
try {
|
||||
Trace::Subject *subject = _subjects.lookup_by_id(subject_id);
|
||||
subject->trace(policy_id, _policies.dataspace(*this, policy_id),
|
||||
policy_size, _ram, buffer_size);
|
||||
} catch (...) {
|
||||
/* revert withdrawal or quota and re-throw exception */
|
||||
/* revert withdrawal or quota */
|
||||
_md_alloc.upgrade(required_ram);
|
||||
throw;
|
||||
throw Out_of_metadata();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user