From 67481fdfc30dc1508375fb4d144a5ccd3b2a6410 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 4 May 2017 18:06:42 +0200 Subject: [PATCH] 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. --- repos/base/src/lib/base/slab.cc | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/repos/base/src/lib/base/slab.cc b/repos/base/src/lib/base/slab.cc index 22094a6a06..39fa829a84 100644 --- a/repos/base/src/lib/base/slab.cc +++ b/repos/base/src/lib/base/slab.cc @@ -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 */