mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
No need for lengthy semaphore names on macOS, pointer address is enough
Also check on init failure and at least log, same as on UNIX
This commit is contained in:
parent
c479230d71
commit
91bc21c489
|
@ -905,8 +905,10 @@ void sphore_destroy(SEMAPHORE *sem) { CloseHandle((HANDLE)*sem); }
|
|||
void sphore_init(SEMAPHORE *sem)
|
||||
{
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "/%d-ddnet.tw-%p", pid(), (void *)sem);
|
||||
str_format(aBuf, sizeof(aBuf), "%p", (void *)sem);
|
||||
*sem = sem_open(aBuf, O_CREAT | O_EXCL, S_IRWXU | S_IRWXG, 0);
|
||||
if(*sem == SEM_FAILED)
|
||||
dbg_msg("sphore", "init failed: %d", errno);
|
||||
}
|
||||
void sphore_wait(SEMAPHORE *sem) { sem_wait(*sem); }
|
||||
void sphore_signal(SEMAPHORE *sem) { sem_post(*sem); }
|
||||
|
@ -914,7 +916,7 @@ void sphore_destroy(SEMAPHORE *sem)
|
|||
{
|
||||
char aBuf[64];
|
||||
sem_close(*sem);
|
||||
str_format(aBuf, sizeof(aBuf), "/%d-ddnet.tw-%p", pid(), (void *)sem);
|
||||
str_format(aBuf, sizeof(aBuf), "%p", (void *)sem);
|
||||
sem_unlink(aBuf);
|
||||
}
|
||||
#elif defined(CONF_FAMILY_UNIX)
|
||||
|
|
Loading…
Reference in a new issue