Skip to content

Commit 2497e20

Browse files
committed
Fix bug in semaphore_init introduced in ce48035
1 parent ccee157 commit 2497e20

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

threading.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,22 @@ int semaphore_init(
7878
*semaphore = CreateSemaphore(NULL, value, 65535, NULL);
7979
if (*semaphore == NULL)
8080
return GetLastError();
81-
else
82-
return 0;
8381
#else
8482
// Mac OS X doesn't support unnamed semaphores via sem_init, that's why
8583
// we use sem_open instead sem_init and immediately unlink the semaphore
8684
// from the name. More info at:
8785
//
8886
// http://stackoverflow.com/questions/1413785/sem-init-on-os-x
8987
*semaphore = sem_open("/semaphore", O_CREAT, S_IRUSR, value);
88+
9089
if (*semaphore == SEM_FAILED)
9190
return errno;
92-
else
93-
return 0;
91+
9492
if (sem_unlink("/semaphore") != 0)
9593
return errno;
9694
#endif
95+
96+
return 0;
9797
}
9898

9999

0 commit comments

Comments
 (0)