Merge pull request #5821 from slavanap/master

Make MMapMemoryAllocator map files in read-only (O_RDONLY) mode
This commit is contained in:
Denis Chapligin 2020-09-09 14:09:31 +03:00 committed by GitHub
commit 4a47267455
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -33,7 +33,7 @@ class MMapMemoryAllocator : public ContiguousBlockAllocator
private:
storage::SharedDataIndex index;
std::vector<boost::iostreams::mapped_file> mapped_memory_files;
std::vector<boost::iostreams::mapped_file_source> mapped_memory_files;
std::string rtree_filename;
};

View File

@ -52,11 +52,11 @@ MMapMemoryAllocator::MMapMemoryAllocator(const storage::StorageConfig &config)
{
std::unique_ptr<storage::BaseDataLayout> layout =
std::make_unique<storage::TarDataLayout>();
boost::iostreams::mapped_file mapped_memory_file;
util::mmapFile<char>(file.second, mapped_memory_file);
boost::iostreams::mapped_file_source mapped_memory_file;
auto data = util::mmapFile<char>(file.second, mapped_memory_file).data();
mapped_memory_files.push_back(std::move(mapped_memory_file));
storage::populateLayoutFromFile(file.second, *layout);
allocated_regions.push_back({mapped_memory_file.data(), std::move(layout)});
allocated_regions.push_back({const_cast<char *>(data), std::move(layout)});
}
}