summaryrefslogtreecommitdiff
path: root/lib/libpthread/uthread
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2001-11-12 21:13:35 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2001-11-12 21:13:35 +0000
commit7050fd8094e3f36135ef4319de7a2898a8725893 (patch)
tree0ee2957d0d46d107078dcc26d63d15fc7f423c3e /lib/libpthread/uthread
parent01a30b1dd1a8cf12cf1a973f069be2cd51019278 (diff)
a better fix for recursive mutex.
Diffstat (limited to 'lib/libpthread/uthread')
-rw-r--r--lib/libpthread/uthread/uthread_mutex.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/lib/libpthread/uthread/uthread_mutex.c b/lib/libpthread/uthread/uthread_mutex.c
index 4fc3962fa83..25a56da6680 100644
--- a/lib/libpthread/uthread/uthread_mutex.c
+++ b/lib/libpthread/uthread/uthread_mutex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_mutex.c,v 1.12 2001/11/12 02:24:30 marc Exp $ */
+/* $OpenBSD: uthread_mutex.c,v 1.13 2001/11/12 21:13:34 fgsch Exp $ */
/*
* Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
* All rights reserved.
@@ -438,10 +438,6 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
/* Lock the mutex for this thread: */
(*mutex)->m_owner = _thread_run;
- /* if recursive, increment the lock count */
- if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE)
- (*mutex)->m_data.m_count++;
-
/* Add to the list of owned mutexes: */
_MUTEX_ASSERT_NOT_OWNED(*mutex);
TAILQ_INSERT_TAIL(&_thread_run->mutexq,
@@ -481,10 +477,6 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
/* Lock the mutex for this thread: */
(*mutex)->m_owner = _thread_run;
- /* if recursive, increment the lock count */
- if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE)
- (*mutex)->m_data.m_count++;
-
/* Track number of priority mutexes owned: */
_thread_run->priority_mutex_count++;
@@ -549,10 +541,6 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
*/
(*mutex)->m_owner = _thread_run;
- /* if recursive, increment the lock count */
- if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE)
- (*mutex)->m_data.m_count++;
-
/* Track number of priority mutexes owned: */
_thread_run->priority_mutex_count++;
@@ -751,7 +739,7 @@ mutex_unlock_common(pthread_mutex_t * mutex, int add_reference)
ret = EPERM;
}
else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
- ((*mutex)->m_data.m_count > 1)) {
+ ((*mutex)->m_data.m_count > 0)) {
/* Decrement the count: */
(*mutex)->m_data.m_count--;
} else {
@@ -810,7 +798,7 @@ mutex_unlock_common(pthread_mutex_t * mutex, int add_reference)
ret = EPERM;
}
else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
- ((*mutex)->m_data.m_count > 1)) {
+ ((*mutex)->m_data.m_count > 0)) {
/* Decrement the count: */
(*mutex)->m_data.m_count--;
} else {
@@ -919,7 +907,7 @@ mutex_unlock_common(pthread_mutex_t * mutex, int add_reference)
ret = EPERM;
}
else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
- ((*mutex)->m_data.m_count > 1)) {
+ ((*mutex)->m_data.m_count > 0)) {
/* Decrement the count: */
(*mutex)->m_data.m_count--;
} else {