From 4cdffafe88524028ae28fc183b5d10619ea8dc52 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 29 Mar 2017 14:58:12 +0100 Subject: [PATCH] [sm_recursive] Fix bug that allowed the same block to be allocated twice. See issue 70. Soln from mingnus. --- persistent-data/space-maps/recursive.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/persistent-data/space-maps/recursive.cc b/persistent-data/space-maps/recursive.cc index dadbe88..0977e61 100644 --- a/persistent-data/space-maps/recursive.cc +++ b/persistent-data/space-maps/recursive.cc @@ -97,6 +97,12 @@ namespace { add_op(b, block_op(SET, c)); else { recursing_lock lock(*this); + + // the inner set_count may trigger a find_free, + // so it's important we update the allocated + // blocks list before calling. + allocated_blocks_.add(b, b + 1); + return sm_->set_count(b, c); } } @@ -111,6 +117,12 @@ namespace { add_op(b, block_op(INC, count)); else { recursing_lock lock(*this); + + // the inner inc() may trigger a find_free, + // so it's important we update the allocated + // blocks list before calling. + allocated_blocks_.add(b, b + 1); + return sm_->inc(b, count); } }