base: support exceptions during _new_slab_block

With the introduction of the 'Out_of_caps' exception type, the slab
needs to consider exceptions during the call of '_new_slab_block' by
reverting the 'nested' state.
This commit is contained in:
Norman Feske 2017-05-04 18:06:42 +02:00 committed by Christian Helmuth
parent c79155fd7b
commit 67481fdfc3

View File

@ -339,17 +339,25 @@ bool Slab::alloc(size_t size, void **out_addr)
/* allocate new block for slab */
_nested = true;
Block * const sb = _new_slab_block();
_nested = false;
if (!sb) return false;
try {
Block * const sb = _new_slab_block();
/*
* The new block has the maximum number of available slots and
* so we can insert it at the beginning of the sorted block
* list.
*/
_insert_sb(sb);
_nested = false;
if (!sb) return false;
/*
* The new block has the maximum number of available slots and
* so we can insert it at the beginning of the sorted block
* list.
*/
_insert_sb(sb);
}
catch (...) {
_nested = false;
throw;
}
}
/* skip completely occupied slab blocks, detect cycles */