diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2005-09-06 19:22:54 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2005-09-06 19:22:54 +0000 |
commit | 75833f08cd845632e2706cdbcc1df86607f73117 (patch) | |
tree | 693bb99e2d9c2f75a991fe1dd3cc1b7f0b246b17 /winsup/cygwin | |
parent | 5843726e51e0cc7463e6c271febe5b40025b9b6e (diff) | |
download | cygnal-75833f08cd845632e2706cdbcc1df86607f73117.tar.gz cygnal-75833f08cd845632e2706cdbcc1df86607f73117.tar.bz2 cygnal-75833f08cd845632e2706cdbcc1df86607f73117.zip |
* thread.h: Revert patch from 2005-09-05.
* thread.cc (pthread_mutex::can_be_unlocked): Return true also if
mutex is owned by MUTEX_OWNER_ANONYMOUS.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/thread.cc | 9 | ||||
-rw-r--r-- | winsup/cygwin/thread.h | 14 |
3 files changed, 21 insertions, 8 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 79e62e8e7..d5ffcecf8 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2005-09-06 Corinna Vinschen <corinna@vinschen.de> + + * thread.h: Revert patch from 2005-09-05. + * thread.cc (pthread_mutex::can_be_unlocked): Return true also if + mutex is owned by MUTEX_OWNER_ANONYMOUS. + 2005-09-05 Christopher Faylor <cgf@timesys.com> * cygheap.cc (cygheap_init): Eliminate debugging #if. 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 diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index f8ab9da8b..c15ded478 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -301,21 +301,27 @@ public: int type; int pshared; + pthread_t get_pthread_self () const + { + return PTHREAD_MUTEX_NORMAL == type ? MUTEX_OWNER_ANONYMOUS : + ::pthread_self (); + } + int lock () { - return _lock (::pthread_self ()); + return _lock (get_pthread_self ()); } int trylock () { - return _trylock (::pthread_self ()); + return _trylock (get_pthread_self ()); } int unlock () { - return _unlock (::pthread_self ()); + return _unlock (get_pthread_self ()); } int destroy () { - return _destroy (::pthread_self ()); + return _destroy (get_pthread_self ()); } void set_owner (pthread_t self) |