[Memory] Close shared memory FD and properly handle its invalid value

This commit is contained in:
Triang3l
2020-11-22 14:17:37 +03:00
parent 432369ae84
commit 86ae42919d
7 changed files with 30 additions and 19 deletions

View File

@@ -40,11 +40,11 @@ X64CodeCache::~X64CodeCache() {
}
// Unmap all views and close mapping.
if (mapping_) {
if (mapping_ != xe::memory::kFileMappingHandleInvalid) {
xe::memory::UnmapFileView(mapping_, generated_code_base_,
kGeneratedCodeSize);
xe::memory::CloseFileMappingHandle(mapping_, file_name_);
mapping_ = nullptr;
mapping_ = xe::memory::kFileMappingHandleInvalid;
}
}
@@ -67,7 +67,7 @@ bool X64CodeCache::Initialize() {
mapping_ = xe::memory::CreateFileMappingHandle(
file_name_, kGeneratedCodeSize, xe::memory::PageAccess::kExecuteReadWrite,
false);
if (!mapping_) {
if (mapping_ == xe::memory::kFileMappingHandleInvalid) {
XELOGE("Unable to create code cache mmap");
return false;
}