about summary refs log tree commit diff
path: root/nptl/pthread_mutex_timedlock.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-05-18 00:55:10 +0000
committerUlrich Drepper <drepper@redhat.com>2007-05-18 00:55:10 +0000
commit113ad5fc9192340269d2ce19b896d51309e785ea (patch)
tree0028c672ecec9626a07fa3dfc5bcba89b690d2f4 /nptl/pthread_mutex_timedlock.c
parentbec51a302f0e7046fcb8c4fcd13ea2969a43a9b7 (diff)
downloadglibc-113ad5fc9192340269d2ce19b896d51309e785ea.tar.gz
glibc-113ad5fc9192340269d2ce19b896d51309e785ea.tar.xz
glibc-113ad5fc9192340269d2ce19b896d51309e785ea.zip
[BZ #4512]
	* pthread_mutex_lock.c: Preserve FUTEX_WAITERS bit when dead owner
	is detected.
	* pthread_mutex_timedlock.c: Likewise.
	* pthread_mutex_trylock.c: Likewise.
	Patch in part by Atsushi Nemoto <anemo@mba.ocn.ne.jp>.

	* Makefile (tests): Add tst-robust9 and tst-robustpi9.
	* tst-robust9.c: New file.
	* tst-robustpi9.c: New file.
Diffstat (limited to 'nptl/pthread_mutex_timedlock.c')
-rw-r--r--nptl/pthread_mutex_timedlock.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
index c8e6b8507a..8fd681c6ef 100644
--- a/nptl/pthread_mutex_timedlock.c
+++ b/nptl/pthread_mutex_timedlock.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -119,9 +119,11 @@ pthread_mutex_timedlock (mutex, abstime)
 	  if ((oldval & FUTEX_OWNER_DIED) != 0)
 	    {
 	      /* The previous owner died.  Try locking the mutex.  */
-	      int newval
+	      int newval = id | (oldval & FUTEX_WAITERS);
+
+	      newval
 		= atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
-						       id, oldval);
+						       newval, oldval);
 	      if (newval != oldval)
 		{
 		  oldval = newval;