[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

@@ -113,11 +113,11 @@ Memory::~Memory() {
heaps_.physical.Dispose();
// Unmap all views and close mapping.
if (mapping_) {
if (mapping_ != xe::memory::kFileMappingHandleInvalid) {
UnmapViews();
xe::memory::CloseFileMappingHandle(mapping_, file_name_);
mapping_base_ = nullptr;
mapping_ = nullptr;
mapping_ = xe::memory::kFileMappingHandleInvalid;
}
virtual_membase_ = nullptr;
@@ -133,9 +133,9 @@ bool Memory::Initialize() {
file_name_,
// entire 4gb space + 512mb physical:
0x11FFFFFFF, xe::memory::PageAccess::kReadWrite, false);
if (!mapping_) {
if (mapping_ == xe::memory::kFileMappingHandleInvalid) {
XELOGE("Unable to reserve the 4gb guest address space.");
assert_not_null(mapping_);
assert_always();
return false;
}