aboutsummaryrefslogtreecommitdiff
path: root/libobjc/thr-posix.c
diff options
context:
space:
mode:
authorChris Ball <cball@fmco.com>1999-09-29 00:37:49 +0000
committerOvidiu Predescu <ovidiu@gcc.gnu.org>1999-09-29 00:37:49 +0000
commit224a6bca72f55814fda63e6ffdd051611ae6c9d4 (patch)
treead4339b76e285ab19d6102f0c2f74853669cd952 /libobjc/thr-posix.c
parentab31268c62837c1d45d7fa6e332170129fa3aa05 (diff)
downloadgcc-224a6bca72f55814fda63e6ffdd051611ae6c9d4.zip
gcc-224a6bca72f55814fda63e6ffdd051611ae6c9d4.tar.gz
gcc-224a6bca72f55814fda63e6ffdd051611ae6c9d4.tar.bz2
Fixed deallocation of a mutex in thr-single.c (patch from Chris Ball <cball@fmco.com>).
From-SVN: r29701
Diffstat (limited to 'libobjc/thr-posix.c')
-rw-r--r--libobjc/thr-posix.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libobjc/thr-posix.c b/libobjc/thr-posix.c
index 5b40f71..a73c627 100644
--- a/libobjc/thr-posix.c
+++ b/libobjc/thr-posix.c
@@ -145,6 +145,20 @@ __objc_mutex_allocate(objc_mutex_t mutex)
int
__objc_mutex_deallocate(objc_mutex_t mutex)
{
+ int count = 1;
+
+ /*
+ * Posix Threads specifically require that the thread be unlocked for
+ * pthread_mutex_destroy to work.
+ */
+
+ while ( count )
+ {
+ if (( count = pthread_mutex_unlock((pthread_mutex_t *)mutex->backend))
+ < 0 )
+ return -1;
+ }
+
if (pthread_mutex_destroy((pthread_mutex_t *)mutex->backend))
return -1;