]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2850] Assert that the segment is not grown during allMemoryDeallocated()
authorJINMEI Tatuya <jinmei@isc.org>
Mon, 3 Jun 2013 05:41:43 +0000 (11:11 +0530)
committerMukund Sivaraman <muks@isc.org>
Mon, 3 Jun 2013 05:41:43 +0000 (11:11 +0530)
src/lib/util/memory_segment_mapped.cc

index f36ad71cd21c9b6b8edf083b2bd092950051883c..9300cae28b42b473049f71532b6920de92e09936 100644 (file)
@@ -137,7 +137,7 @@ struct MemorySegmentMapped::Impl {
         reserveMemory();
     }
 
-    void reserveMemory() {
+    void reserveMemory(bool no_grow = false) {
         if (!read_only_) {
             // Reserve a named address for use during
             // setNamedAddress(). Though this will almost always succeed
@@ -153,6 +153,7 @@ struct MemorySegmentMapped::Impl {
                 if (reserved_storage) {
                     break;
                 }
+                assert(!no_grow);
 
                 growSegment();
             }
@@ -332,8 +333,8 @@ MemorySegmentMapped::allMemoryDeallocated() const {
         impl_->freeReservedMemory();
         const bool result = impl_->base_sgmt_->all_memory_deallocated();
         // reserveMemory() should succeed now as the memory was already
-        // allocated.
-        impl_->reserveMemory();
+        // allocated, so we set no_grow to true.
+        impl_->reserveMemory(true);
         return (result);
     } catch (...) {
         abort();