about summary refs log tree commit diff
path: root/nptl/pthread_mutex_trylock.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_trylock.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_trylock.c')
-rw-r--r--nptl/pthread_mutex_trylock.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
index 4990ecd711..9db904c60b 100644
--- a/nptl/pthread_mutex_trylock.c
+++ b/nptl/pthread_mutex_trylock.c
@@ -84,9 +84,11 @@ __pthread_mutex_trylock (mutex)
 	  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)
 		{