summaryrefslogtreecommitdiffstats
path: root/lib/libkse/thread/thr_mutex.c
diff options
context:
space:
mode:
authorjb <jb@FreeBSD.org>1999-05-23 10:55:33 +0000
committerjb <jb@FreeBSD.org>1999-05-23 10:55:33 +0000
commit46db87a1e419b1c77d616f221dab956228910cf3 (patch)
tree02a9057f5b70cc09e45507a055e5fcf4a3ceeb24 /lib/libkse/thread/thr_mutex.c
parent3162b42ed3feed4271a715812219251af3da2c0e (diff)
downloadFreeBSD-src-46db87a1e419b1c77d616f221dab956228910cf3.zip
FreeBSD-src-46db87a1e419b1c77d616f221dab956228910cf3.tar.gz
Fix a problem with static initialisation of mutexes and condition
variables. Submitted by: Dan Eischen <eischen@vigrid.com>
Diffstat (limited to 'lib/libkse/thread/thr_mutex.c')
-rw-r--r--lib/libkse/thread/thr_mutex.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/libkse/thread/thr_mutex.c b/lib/libkse/thread/thr_mutex.c
index 0103a6c..fa9c8cf 100644
--- a/lib/libkse/thread/thr_mutex.c
+++ b/lib/libkse/thread/thr_mutex.c
@@ -222,6 +222,15 @@ pthread_mutex_trylock(pthread_mutex_t * mutex)
*/
else if (*mutex != NULL || (ret = init_static(mutex)) == 0) {
/*
+ * If the mutex was statically allocated, properly
+ * initialize the tail queue.
+ */
+ if (((*mutex)->m_flags & MUTEX_FLAGS_INITED) == 0) {
+ TAILQ_INIT(&(*mutex)->m_queue);
+ (*mutex)->m_flags |= MUTEX_FLAGS_INITED;
+ }
+
+ /*
* Guard against being preempted by a scheduling signal.
* To support priority inheritence mutexes, we need to
* maintain lists of mutex ownerships for each thread as
@@ -352,6 +361,15 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
*/
else if (*mutex != NULL || (ret = init_static(mutex)) == 0) {
/*
+ * If the mutex was statically allocated, properly
+ * initialize the tail queue.
+ */
+ if (((*mutex)->m_flags & MUTEX_FLAGS_INITED) == 0) {
+ TAILQ_INIT(&(*mutex)->m_queue);
+ (*mutex)->m_flags |= MUTEX_FLAGS_INITED;
+ }
+
+ /*
* Guard against being preempted by a scheduling signal.
* To support priority inheritence mutexes, we need to
* maintain lists of mutex ownerships for each thread as
OpenPOWER on IntegriCloud