mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 14:08:19 +00:00
Merge pull request #8776 from Robyt3/Base-Semaphore-macOS-Unique-Name
Make macOS semaphore names more unique, improve assertion
This commit is contained in:
commit
54271aef2a
|
@ -867,10 +867,15 @@ void sphore_destroy(SEMAPHORE *sem)
|
|||
#elif defined(CONF_PLATFORM_MACOS)
|
||||
void sphore_init(SEMAPHORE *sem)
|
||||
{
|
||||
char aBuf[32];
|
||||
str_format(aBuf, sizeof(aBuf), "%p", (void *)sem);
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "/%d.%p", pid(), (void *)sem);
|
||||
*sem = sem_open(aBuf, O_CREAT | O_EXCL, S_IRWXU | S_IRWXG, 0);
|
||||
dbg_assert(*sem != SEM_FAILED, "sem_open failure");
|
||||
if(*sem == SEM_FAILED)
|
||||
{
|
||||
char aError[128];
|
||||
str_format(aError, sizeof(aError), "sem_open failure, errno=%d, name='%s'", errno, aBuf);
|
||||
dbg_assert(false, aError);
|
||||
}
|
||||
}
|
||||
void sphore_wait(SEMAPHORE *sem)
|
||||
{
|
||||
|
@ -888,8 +893,8 @@ void sphore_signal(SEMAPHORE *sem)
|
|||
void sphore_destroy(SEMAPHORE *sem)
|
||||
{
|
||||
dbg_assert(sem_close(*sem) == 0, "sem_close failure");
|
||||
char aBuf[32];
|
||||
str_format(aBuf, sizeof(aBuf), "%p", (void *)sem);
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "/%d.%p", pid(), (void *)sem);
|
||||
dbg_assert(sem_unlink(aBuf) == 0, "sem_unlink failure");
|
||||
}
|
||||
#elif defined(CONF_FAMILY_UNIX)
|
||||
|
|
Loading…
Reference in a new issue