Browse Source

[2836-2] make sure flush()ing the base segment before grow/shrink

I was confused at the time I removed it in #2831.  these were actually
necessary.
JINMEI Tatuya 12 years ago
parent
commit
7184eb4185
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/lib/util/memory_segment_mapped.cc

+ 3 - 1
src/lib/util/memory_segment_mapped.cc

@@ -129,6 +129,7 @@ struct MemorySegmentMapped::Impl {
     void growSegment() {
         // We first need to unmap it before calling grow().
         const size_t prev_size = base_sgmt_->get_size();
+        base_sgmt_->flush();
         base_sgmt_.reset();
 
         // Double the segment size.  In theory, this process could repeat
@@ -341,7 +342,8 @@ MemorySegmentMapped::shrinkToFit() {
         return;
     }
 
-    // First, (unmap and) close the underlying file.
+    // First, unmap the underlying file.
+    impl_->base_sgmt_->flush();
     impl_->base_sgmt_.reset();
 
     BaseSegment::shrink_to_fit(impl_->filename_.c_str());