nova: use lock guard instead of explicit calls

If an exception is thrown the lock is released automatically, so that
other callers may get a capability index if in between some are freed. Fixes
some deadlocks if Genode is short on capability indexes.

Related to #625
This commit is contained in:
Alexander Boettcher 2013-01-17 16:10:29 +01:00 committed by Norman Feske
parent 17ca0290a1
commit e817163f1a
1 changed files with 3 additions and 6 deletions

View File

@ -36,18 +36,15 @@ static Genode::Lock *alloc_lock()
addr_t Cap_selector_allocator::alloc(size_t num_caps_log2)
{
alloc_lock()->lock();
addr_t ret_base = Bit_allocator::alloc(num_caps_log2);
alloc_lock()->unlock();
return ret_base;
Lock::Guard(alloc_lock());
return Bit_allocator::alloc(num_caps_log2);
}
void Cap_selector_allocator::free(addr_t cap, size_t num_caps_log2)
{
alloc_lock()->lock();
Lock::Guard(alloc_lock());
Bit_allocator::free(cap, num_caps_log2);
alloc_lock()->unlock();
}