diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2017-10-26 20:56:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-26 20:56:22 +0200 |
| commit | 3f6017343b91e079996ab16db03791ac907b4172 (patch) | |
| tree | 54e5c053b1a435a68070e0ceef0b0331adbc1ff4 /Source/Core/Common/MemArena.cpp | |
| parent | c4914fbb8b9d90e1acdd77ce7504a0e4c4dfd21f (diff) | |
| parent | 28d648b80278161e21e370e326be4de4a8645340 (diff) | |
Merge pull request #6114 from leoetlino/fix
MemArena: Use names that are based on the PID
Diffstat (limited to 'Source/Core/Common/MemArena.cpp')
| -rw-r--r-- | Source/Core/Common/MemArena.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/Source/Core/Common/MemArena.cpp b/Source/Core/Common/MemArena.cpp index d9b3d1a37c..750a240e19 100644 --- a/Source/Core/Common/MemArena.cpp +++ b/Source/Core/Common/MemArena.cpp @@ -55,31 +55,25 @@ static int AshmemCreateFileMapping(const char* name, size_t size) void MemArena::GrabSHMSegment(size_t size) { #ifdef _WIN32 + const std::string name = "dolphin-emu." + std::to_string(GetCurrentProcessId()); hMemoryMapping = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, - static_cast<DWORD>(size), L"Dolphin-emu"); + static_cast<DWORD>(size), UTF8ToTStr(name).c_str()); #elif defined(ANDROID) - fd = AshmemCreateFileMapping("Dolphin-emu", size); + fd = AshmemCreateFileMapping(("dolphin-emu." + std::to_string(getpid())).c_str(), size); if (fd < 0) { NOTICE_LOG(MEMMAP, "Ashmem allocation failed"); return; } #else - for (int i = 0; i < 10000; i++) + const std::string file_name = "/dolphin-emu." + std::to_string(getpid()); + fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); + if (fd == -1) { - std::string file_name = StringFromFormat("/dolphinmem.%d", i); - fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); - if (fd != -1) - { - shm_unlink(file_name.c_str()); - break; - } - else if (errno != EEXIST) - { - ERROR_LOG(MEMMAP, "shm_open failed: %s", strerror(errno)); - return; - } + ERROR_LOG(MEMMAP, "shm_open failed: %s", strerror(errno)); + return; } + shm_unlink(file_name.c_str()); if (ftruncate(fd, size) < 0) ERROR_LOG(MEMMAP, "Failed to allocate low memory space"); #endif |
