about summary refs log tree commit diff
path: root/nptl/pthread_rwlock_trywrlock.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-08-30 19:11:05 +0000
committerUlrich Drepper <drepper@redhat.com>2006-08-30 19:11:05 +0000
commitbee2df0bb966087d7f57d935a4234ffe30c76196 (patch)
tree045458320a987e129ff0770f957de833bd43f4d5 /nptl/pthread_rwlock_trywrlock.c
parent99ea5991a4957f7a21466a4b48c5020eb70db2b7 (diff)
downloadglibc-bee2df0bb966087d7f57d935a4234ffe30c76196.tar.gz
glibc-bee2df0bb966087d7f57d935a4234ffe30c76196.tar.xz
glibc-bee2df0bb966087d7f57d935a4234ffe30c76196.zip
* pthread_rwlock_trywrlock.c (__pthread_rwlock_trywrlock): Respect cvs/fedora-glibc-20060831T0640
	reader preference.
	* sysdeps/pthread/pthread_rwlock_timedwrlock.c
	(pthread_rwlock_timedwrlock): Likewise.
	* sysdeps/pthread/pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock):
	Likewise.
Diffstat (limited to 'nptl/pthread_rwlock_trywrlock.c')
-rw-r--r--nptl/pthread_rwlock_trywrlock.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/nptl/pthread_rwlock_trywrlock.c b/nptl/pthread_rwlock_trywrlock.c
index b754a19565..63760064c5 100644
--- a/nptl/pthread_rwlock_trywrlock.c
+++ b/nptl/pthread_rwlock_trywrlock.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -30,7 +30,10 @@ __pthread_rwlock_trywrlock (rwlock)
 
   lll_mutex_lock (rwlock->__data.__lock);
 
-  if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0)
+  if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0
+      /* Respect the preference.  */
+      && (rwlock->__data.__flags != 0
+	  || rwlock->__data.__nr_readers_queued == 0))
     {
       rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid);
       result = 0;