[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Fixes for generic pthread_cond_*wait functions



This patch fixes one error found by one of the test programs, plus
another where the behaviour of the generic pthread_cond_wait function
differs from the x86 version.  The first error is that
pthread_cond_timedwait doesn't return an error (as it should) if it
gets an error unlocking the mutex.  The second is that if
pthread_cond_wait gets an error relocking the mutex, it doesn't return
the error.  This patch fixes both.

Paul.

diff -urN nptl-0.28/nptl/sysdeps/pthread/pthread_cond_timedwait.c libc/nptl/sysdeps/pthread/pthread_cond_timedwait.c
--- nptl-0.28/nptl/sysdeps/pthread/pthread_cond_timedwait.c	2003-03-04 08:01:23.000000000 +1100
+++ libc/nptl/sysdeps/pthread/pthread_cond_timedwait.c	2003-03-11 20:01:05.000000000 +1100
@@ -47,6 +47,7 @@
   struct _pthread_cleanup_buffer buffer;
   struct _condvar_cleanup_buffer cbuffer;
   int result = 0;
+  int err;
 
   /* Catch invalid parameters.  */
   if (abstime->tv_nsec >= 1000000000)
@@ -56,7 +57,12 @@
   lll_mutex_lock (cond->__data.__lock);
 
   /* Now we can release the mutex.  */
-  __pthread_mutex_unlock_internal (mutex);
+  err = __pthread_mutex_unlock_internal (mutex);
+  if (err)
+    {
+      lll_mutex_unlock (cond->__data.__lock);
+      return err;
+    }
 
   /* We have one new user of the condvar.  */
   ++cond->__data.__total_seq;
@@ -87,8 +93,6 @@
 
   while (1)
     {
-      int err;
-
       /* Get the current time.  So far we support only one clock.  */
       struct timeval tv;
       (void) gettimeofday (&tv, NULL);
diff -urN nptl-0.28/nptl/sysdeps/pthread/pthread_cond_wait.c libc/nptl/sysdeps/pthread/pthread_cond_wait.c
--- nptl-0.28/nptl/sysdeps/pthread/pthread_cond_wait.c	2003-03-04 08:01:23.000000000 +1100
+++ libc/nptl/sysdeps/pthread/pthread_cond_wait.c	2003-03-11 20:01:15.000000000 +1100
@@ -141,9 +141,7 @@
   __pthread_cleanup_pop (&buffer, 0);
 
   /* Get the mutex before returning.  */
-  __pthread_mutex_lock_internal (mutex);
-
-  return 0;
+  return __pthread_mutex_lock_internal (mutex);
 }
 
 versioned_symbol (libpthread, __pthread_cond_wait, pthread_cond_wait,





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]