mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-17 07:50:04 +00:00
LibCore: Ensure shared memory file names on macOS are unique
At least on my mac, clock_gettime only provides millisecond resolution. So if many WebContent processes are opened at once, it is not unlikely that they will all create their backing stores within the same ms. When that happens, all but the first will fail (and crash). To prevent this, generate the shared memory file name based on the PID and a static counter.
This commit is contained in:
parent
aa1df95b31
commit
5056bda043
Notes:
github-actions[bot]
2024-10-06 05:49:03 +00:00
Author: https://github.com/trflynn89
Commit: 5056bda043
1 changed files with 3 additions and 3 deletions
|
@ -528,9 +528,9 @@ ErrorOr<int> anon_create([[maybe_unused]] size_t size, [[maybe_unused]] int opti
|
|||
return Error::from_errno(saved_errno);
|
||||
}
|
||||
#elif defined(AK_OS_BSD_GENERIC) || defined(AK_OS_EMSCRIPTEN) || defined(AK_OS_HAIKU)
|
||||
struct timespec time;
|
||||
clock_gettime(CLOCK_REALTIME, &time);
|
||||
auto name = ByteString::formatted("/shm-{}{}", (unsigned long)time.tv_sec, (unsigned long)time.tv_nsec);
|
||||
static size_t shared_memory_id = 0;
|
||||
|
||||
auto name = ByteString::formatted("/shm-{}-{}", getpid(), shared_memory_id++);
|
||||
fd = shm_open(name.characters(), O_RDWR | O_CREAT | options, 0600);
|
||||
|
||||
if (shm_unlink(name.characters()) == -1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue