summaryrefslogtreecommitdiff
path: root/lib/libpthread/uthread/uthread_mutex.c
diff options
context:
space:
mode:
authorMarco S Hyman <marc@cvs.openbsd.org>2001-11-12 02:24:31 +0000
committerMarco S Hyman <marc@cvs.openbsd.org>2001-11-12 02:24:31 +0000
commit11c30e289f54a168d95ce9734017853b21169f73 (patch)
treee8de6840f9a07d3643ac8b9c0d1e54f7a7c10575 /lib/libpthread/uthread/uthread_mutex.c
parent66e5aa528eab6994ebf607531cdd9fb833e8aad0 (diff)
This fixes the recursive mutex problem with pthreads.
fgs@ says their is a better fix... if so he can back these changes out and apply his fix at his convenience. In the meanwhile we'll have mutexen that work.
Diffstat (limited to 'lib/libpthread/uthread/uthread_mutex.c')
-rw-r--r--lib/libpthread/uthread/uthread_mutex.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/libpthread/uthread/uthread_mutex.c b/lib/libpthread/uthread/uthread_mutex.c
index 782808b5831..4fc3962fa83 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.11 2000/01/06 07:19:35 d Exp $ */
+/* $OpenBSD: uthread_mutex.c,v 1.12 2001/11/12 02:24:30 marc Exp $ */
/*
* Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
* All rights reserved.
@@ -134,7 +134,7 @@ pthread_mutex_init(pthread_mutex_t * mutex,
/* Check mutex protocol: */
else if (((*mutex_attr)->m_protocol < PTHREAD_PRIO_NONE) ||
- ((*mutex_attr)->m_protocol > PTHREAD_MUTEX_RECURSIVE))
+ ((*mutex_attr)->m_protocol > PTHREAD_PRIO_PROTECT))
/* Return an invalid argument error: */
ret = EINVAL;
@@ -438,6 +438,10 @@ 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,
@@ -477,6 +481,10 @@ 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++;
@@ -541,6 +549,10 @@ 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++;