Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2010-02-23 10:12:38 +0300
committerChristopher Faylor <me@cgf.cx>2010-02-23 10:12:38 +0300
commit7414c24a7741696cbe4e2da8c2fe9837b866bd5b (patch)
treee34ab59312d123e9916d0b5702f73b188386140a /winsup/cygwin/thread.cc
parentdbf41aeeff4a946d8ed54dccb4d396505cab83d6 (diff)
* thread.cc (pthread_mutex::unlock): Don't attempt to unlock if there is an
error.
Diffstat (limited to 'winsup/cygwin/thread.cc')
-rw-r--r--winsup/cygwin/thread.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 0a44d6965..474f6bd2d 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -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;
}