summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/thread.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/thread.cc')
-rw-r--r--winsup/cygwin/thread.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 9f4899e91..11d60fc0e 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -212,10 +212,11 @@ pthread_mutex::can_be_unlocked (pthread_mutex_t const *mutex)
if (!is_good_object (mutex))
return false;
- /*
- * Check if the mutex is owned by the current thread and can be unlocked
- */
- return ((*mutex)->recursion_counter == 1 && pthread::equal ((*mutex)->owner, self));
+ /* Check if the mutex is owned by the current thread and can be unlocked.
+ * Also check for the ANONYMOUS owner to cover NORMAL mutexes as well. */
+ return ((*mutex)->recursion_counter == 1
+ && ((*mutex)->owner == MUTEX_OWNER_ANONYMOUS
+ || pthread::equal ((*mutex)->owner, self)));
}
inline bool