OSDN Git Service

* thread.cc (pthread_mutex::unlock): Don't attempt to unlock if there is an
authorcgf <cgf>
Tue, 23 Feb 2010 07:12:38 +0000 (07:12 +0000)
committercgf <cgf>
Tue, 23 Feb 2010 07:12:38 +0000 (07:12 +0000)
error.

winsup/cygwin/ChangeLog
winsup/cygwin/thread.cc

index 8ccb684..963b399 100644 (file)
@@ -1,3 +1,8 @@
+2010-02-23  Christopher Faylor  <me+cygwin@cgf.cx>
+
+       * thread.cc (pthread_mutex::unlock): Don't attempt to unlock if there
+       is an error.
+
 2010-02-22  Christopher Faylor  <me+cygwin@cgf.cx>
 
        * include/sys/strace.h: Define _STRACE_SPECIAL.
index 0a44d69..474f6bd 100644 (file)
@@ -1614,15 +1614,15 @@ pthread_mutex::lock ()
 int
 pthread_mutex::unlock ()
 {
-  int res;
+  int res = 0;
   pthread_t self = ::pthread_self ();
   if (type == PTHREAD_MUTEX_NORMAL)
     /* no error checking */;
   else if (no_owner ())
-    return type == PTHREAD_MUTEX_ERRORCHECK ? EINVAL : 0;
+    res = type == PTHREAD_MUTEX_ERRORCHECK ? EINVAL : 0;
   else if (!pthread::equal (owner, self))
     res = EPERM;
-  if (recursion_counter > 0 && --recursion_counter == 0)
+  if (!res && recursion_counter > 0 && --recursion_counter == 0)
     /* Don't try to unlock anything if recursion_counter == 0.
        This means the mutex was never locked or that we've forked. */
     {
@@ -1635,8 +1635,8 @@ pthread_mutex::unlock ()
       res = 0;
     }
 
-  pthread_printf ("mutex %p, owner %p, self %p, lock_counter %d, recursion_counter %d, res %d",
-                 this, owner, self, lock_counter, recursion_counter, res);
+  pthread_printf ("mutex %p, owner %p, self %p, lock_counter %d, recursion_counter %d, type %d, res %d",
+                 this, owner, self, lock_counter, recursion_counter, type, res);
   return res;
 }