aboutsummaryrefslogtreecommitdiff
path: root/nptl/sysdeps/pthread/pthread_rwlock_unlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/sysdeps/pthread/pthread_rwlock_unlock.c')
-rw-r--r--nptl/sysdeps/pthread/pthread_rwlock_unlock.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/nptl/sysdeps/pthread/pthread_rwlock_unlock.c b/nptl/sysdeps/pthread/pthread_rwlock_unlock.c
index 6e0c92ba3f..9cae8b6c22 100644
--- a/nptl/sysdeps/pthread/pthread_rwlock_unlock.c
+++ b/nptl/sysdeps/pthread/pthread_rwlock_unlock.c
@@ -24,27 +24,32 @@
#include <pthreadP.h>
/* Unlock RWLOCK. */
-int __pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
+int
+__pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
{
- lll_mutex_lock(rwlock->__data.__lock);
+ lll_mutex_lock (rwlock->__data.__lock);
if (rwlock->__data.__writer)
rwlock->__data.__writer = 0;
else
- rwlock->__data.__nr_readers--;
- if (!rwlock->__data.__nr_readers)
+ --rwlock->__data.__nr_readers;
+ if (rwlock->__data.__nr_readers == 0)
{
if (rwlock->__data.__nr_writers_queued)
{
++rwlock->__data.__writer_wakeup;
- lll_futex_wake(&rwlock->__data.__writer_wakeup, 1);
+ lll_mutex_unlock (rwlock->__data.__lock);
+ lll_futex_wake (&rwlock->__data.__writer_wakeup, 1);
+ return 0;
}
- else
+ else if (rwlock->__data.__nr_readers_queued)
{
++rwlock->__data.__readers_wakeup;
- lll_futex_wake(&rwlock->__data.__readers_wakeup, INT_MAX);
+ lll_mutex_unlock (rwlock->__data.__lock);
+ lll_futex_wake (&rwlock->__data.__readers_wakeup, INT_MAX);
+ return 0;
}
}
- lll_mutex_unlock(rwlock->__data.__lock);
+ lll_mutex_unlock (rwlock->__data.__lock);
return 0;
}