Skip to content

Commit

Permalink
[semaphore] Fix mono_sem_wait() for Darwin, clean up mono_sem_post().
Browse files Browse the repository at this point in the history
semaphore_wait() never returns -1, but returns KERN_ABORTED if the
call needs to be repeated.  This caused a semaphore wait to sometimes
return in the SGen workers code when it shouldn't, which caused a
mysterious assertion failure.
  • Loading branch information
schani committed Mar 13, 2013
1 parent eefc9d8 commit 5d4ff59
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mono/utils/mono-semaphore.c
Expand Up @@ -112,7 +112,7 @@ mono_sem_wait (MonoSemType *sem, gboolean alertable)
#ifndef USE_MACH_SEMA
while ((res = sem_wait (sem)) == -1 && errno == EINTR)
#else
while ((res = semaphore_wait (*sem)) == -1 && errno == EINTR)
while ((res = semaphore_wait (*sem)) == KERN_ABORTED)
#endif
{
if (alertable)
Expand All @@ -131,9 +131,9 @@ mono_sem_post (MonoSemType *sem)
#ifndef USE_MACH_SEMA
while ((res = sem_post (sem)) == -1 && errno == EINTR);
#else
while ((res = semaphore_signal (*sem)) == -1 && errno == EINTR);
res = semaphore_signal (*sem);
/* OSX might return > 0 for error */
if (res != 0)
if (res != KERN_SUCCESS)
res = -1;
#endif
return res;
Expand Down

0 comments on commit 5d4ff59

Please sign in to comment.