about summary refs log tree commit diff
path: root/nptl/sysdeps/pthread/pthread_cond_wait.c
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/sysdeps/pthread/pthread_cond_wait.c')
-rw-r--r--nptl/sysdeps/pthread/pthread_cond_wait.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/nptl/sysdeps/pthread/pthread_cond_wait.c b/nptl/sysdeps/pthread/pthread_cond_wait.c
index 708566be03..da94cc2d6b 100644
--- a/nptl/sysdeps/pthread/pthread_cond_wait.c
+++ b/nptl/sysdeps/pthread/pthread_cond_wait.c
@@ -65,8 +65,7 @@ __condvar_cleanup (void *arg)
 
   /* Get the mutex before returning unless asynchronous cancellation
      is in effect.  */
-  if (!(cbuffer->oldtype & CANCELTYPE_BITMASK))
-    __pthread_mutex_lock_internal (cbuffer->mutex);
+  __pthread_mutex_cond_lock (cbuffer->mutex);
 }
 
 
@@ -93,6 +92,10 @@ __pthread_cond_wait (cond, mutex)
   /* We have one new user of the condvar.  */
   ++cond->__data.__total_seq;
 
+  /* Remember the mutex we are using here.  If there is already a
+     different address store this is a bad user bug.  */
+  cond->__data.__mutex = mutex;
+
   /* Prepare structure passed to cancellation handler.  */
   cbuffer.cond = cond;
   cbuffer.mutex = mutex;
@@ -123,7 +126,7 @@ __pthread_cond_wait (cond, mutex)
       lll_mutex_unlock (cond->__data.__lock);
 
       /* Enable asynchronous cancellation.  Required by the standard.  */
-      __pthread_enable_asynccancel_2 (&cbuffer.oldtype);
+      cbuffer.oldtype = __pthread_enable_asynccancel ();
 
       /* Wait until woken by signal or broadcast.  Note that we
 	 truncate the 'val' value to 32 bits.  */
@@ -150,7 +153,7 @@ __pthread_cond_wait (cond, mutex)
   __pthread_cleanup_pop (&buffer, 0);
 
   /* Get the mutex before returning.  */
-  return __pthread_mutex_lock_internal (mutex);
+  return __pthread_mutex_cond_lock (mutex);
 }
 
 versioned_symbol (libpthread, __pthread_cond_wait, pthread_cond_wait,