[memory linux] Properly unlink shared memory
shm_unlink(name) is the proper way to close a shared memory in linux. Prior to this, xenia was creating and not cleaning up shared memory handle which would accumulate in /dev/shm. shm_unlink is the proper way of doing this. Add filename to CloseFileMappingHandle signature. Add simple test to open and close.
This commit is contained in:
@@ -97,8 +97,10 @@ FileMappingHandle CreateFileMappingHandle(const std::filesystem::path& path,
|
||||
return ret <= 0 ? nullptr : reinterpret_cast<FileMappingHandle>(ret);
|
||||
}
|
||||
|
||||
void CloseFileMappingHandle(FileMappingHandle handle) {
|
||||
close(static_cast<int>(reinterpret_cast<int64_t>(handle)));
|
||||
void CloseFileMappingHandle(FileMappingHandle handle,
|
||||
const std::filesystem::path& path) {
|
||||
auto full_path = "/" / path;
|
||||
shm_unlink(full_path.c_str());
|
||||
}
|
||||
|
||||
void* MapFileView(FileMappingHandle handle, void* base_address, size_t length,
|
||||
|
||||
Reference in New Issue
Block a user