Allow libc's version of sem_trywait() to work for non-pshared mutexes.
This commit is contained in:
parent
d17387acd4
commit
903f2e5041
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=125446
@ -295,11 +295,26 @@ __sem_wait(sem_t *sem)
|
||||
int
|
||||
__sem_trywait(sem_t *sem)
|
||||
{
|
||||
int retval;
|
||||
|
||||
if (sem_check_validity(sem) != 0)
|
||||
return (-1);
|
||||
|
||||
return (ksem_trywait((*sem)->semid));
|
||||
if ((*sem)->syssem != 0)
|
||||
retval = ksem_trywait((*sem)->semid);
|
||||
else {
|
||||
_pthread_mutex_lock(&(*sem)->lock);
|
||||
if ((*sem)->count != 0) {
|
||||
(*sem)->count--;
|
||||
retval = 0;
|
||||
} else {
|
||||
errno = EAGAIN;
|
||||
retval = -1;
|
||||
}
|
||||
(*sem)->count--;
|
||||
_pthread_mutex_unlock(&(*sem)->lock);
|
||||
}
|
||||
return (retval);
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user