From: Valentin Ghita <[email protected]> Committer: WALDEMAR KOZACZUK <[email protected]> Branch: master
libc/pthread: Make pthread_rwlock_trywrlock/tryrdlock posix compatible The current implementations of pthread_rwlock_trywrlock and pthread_rwlock_tryrdlock don't follow the POSIX specification and return incorrect values. Fix the return values to follow the specification. Signed-off-by: Valentin Ghita <[email protected]> --- diff --git a/libc/pthread.cc b/libc/pthread.cc --- a/libc/pthread.cc +++ b/libc/pthread.cc @@ -501,8 +501,10 @@ int pthread_rwlock_destroy(pthread_rwlock_t *rw) int pthread_rwlock_trywrlock(pthread_rwlock_t *rw) { - from_libc(rw)->try_wlock(); - return 0; + if (from_libc(rw)->try_wlock()) { + return 0; + } + return EBUSY; } int pthread_rwlock_wrlock(pthread_rwlock_t *rw) @@ -519,7 +521,10 @@ int pthread_rwlock_rdlock(pthread_rwlock_t *rw) int pthread_rwlock_tryrdlock(pthread_rwlock_t *rw) { - return from_libc(rw)->try_rlock(); + if (from_libc(rw)->try_rlock()) { + return 0; + } + return EBUSY; } int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr) -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/00000000000080998c06104169da%40google.com.
