mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38: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)
|
#elif defined(CONF_PLATFORM_MACOS)
|
||||||
void sphore_init(SEMAPHORE *sem)
|
void sphore_init(SEMAPHORE *sem)
|
||||||
{
|
{
|
||||||
char aBuf[32];
|
char aBuf[64];
|
||||||
str_format(aBuf, sizeof(aBuf), "%p", (void *)sem);
|
str_format(aBuf, sizeof(aBuf), "/%d.%p", pid(), (void *)sem);
|
||||||
*sem = sem_open(aBuf, O_CREAT | O_EXCL, S_IRWXU | S_IRWXG, 0);
|
*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)
|
void sphore_wait(SEMAPHORE *sem)
|
||||||
{
|
{
|
||||||
|
@ -888,8 +893,8 @@ void sphore_signal(SEMAPHORE *sem)
|
||||||
void sphore_destroy(SEMAPHORE *sem)
|
void sphore_destroy(SEMAPHORE *sem)
|
||||||
{
|
{
|
||||||
dbg_assert(sem_close(*sem) == 0, "sem_close failure");
|
dbg_assert(sem_close(*sem) == 0, "sem_close failure");
|
||||||
char aBuf[32];
|
char aBuf[64];
|
||||||
str_format(aBuf, sizeof(aBuf), "%p", (void *)sem);
|
str_format(aBuf, sizeof(aBuf), "/%d.%p", pid(), (void *)sem);
|
||||||
dbg_assert(sem_unlink(aBuf) == 0, "sem_unlink failure");
|
dbg_assert(sem_unlink(aBuf) == 0, "sem_unlink failure");
|
||||||
}
|
}
|
||||||
#elif defined(CONF_FAMILY_UNIX)
|
#elif defined(CONF_FAMILY_UNIX)
|
||||||
|
|
Loading…
Reference in a new issue