about summary refs log tree commit diff
path: root/nptl/pthread_rwlock_timedrdlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/pthread_rwlock_timedrdlock.c')
-rw-r--r--nptl/pthread_rwlock_timedrdlock.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/nptl/pthread_rwlock_timedrdlock.c b/nptl/pthread_rwlock_timedrdlock.c
index 0212b49adb..63fb313762 100644
--- a/nptl/pthread_rwlock_timedrdlock.c
+++ b/nptl/pthread_rwlock_timedrdlock.c
@@ -23,6 +23,7 @@
 #include <pthreadP.h>
 #include <sys/time.h>
 #include <kernel-features.h>
+#include <stdbool.h>
 
 
 /* Try to acquire read lock for RWLOCK or return after specfied time.  */
@@ -32,6 +33,7 @@ pthread_rwlock_timedrdlock (rwlock, abstime)
      const struct timespec *abstime;
 {
   int result = 0;
+  bool wake = false;
 
   /* Make sure we are alone.  */
   lll_lock(rwlock->__data.__lock, rwlock->__data.__shared);
@@ -53,6 +55,17 @@ pthread_rwlock_timedrdlock (rwlock, abstime)
 	      --rwlock->__data.__nr_readers;
 	      result = EAGAIN;
 	    }
+	  else
+	    {
+	      /* See pthread_rwlock_rdlock.  */
+	      if (rwlock->__data.__nr_readers == 1
+		  && rwlock->__data.__nr_readers_queued > 0
+		  && rwlock->__data.__nr_writers_queued > 0)
+		{
+		  ++rwlock->__data.__readers_wakeup;
+		  wake = true;
+		}
+	    }
 
 	  break;
 	}
@@ -153,5 +166,9 @@ pthread_rwlock_timedrdlock (rwlock, abstime)
   /* We are done, free the lock.  */
   lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
 
+  if (wake)
+    lll_futex_wake (&rwlock->__data.__readers_wakeup, INT_MAX,
+		    rwlock->__data.__shared);
+
   return result;
 }