diff options
author | jb <jb@FreeBSD.org> | 1999-05-23 10:55:33 +0000 |
---|---|---|
committer | jb <jb@FreeBSD.org> | 1999-05-23 10:55:33 +0000 |
commit | 46db87a1e419b1c77d616f221dab956228910cf3 (patch) | |
tree | 02a9057f5b70cc09e45507a055e5fcf4a3ceeb24 /lib/libc_r/uthread/uthread_cond.c | |
parent | 3162b42ed3feed4271a715812219251af3da2c0e (diff) | |
download | FreeBSD-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/libc_r/uthread/uthread_cond.c')
-rw-r--r-- | lib/libc_r/uthread/uthread_cond.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/libc_r/uthread/uthread_cond.c b/lib/libc_r/uthread/uthread_cond.c index c090d79..e0360dd 100644 --- a/lib/libc_r/uthread/uthread_cond.c +++ b/lib/libc_r/uthread/uthread_cond.c @@ -146,6 +146,15 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) */ else if (*cond != NULL || (rval = pthread_cond_init(cond,NULL)) == 0) { + /* + * If the condvar was statically allocated, properly + * initialize the tail queue. + */ + if (((*cond)->c_flags & COND_FLAGS_INITED) == 0) { + TAILQ_INIT(&(*cond)->c_queue); + (*cond)->c_flags |= COND_FLAGS_INITED; + } + /* Lock the condition variable structure: */ _SPINLOCK(&(*cond)->lock); @@ -238,6 +247,16 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, */ else if (*cond != NULL || (rval = pthread_cond_init(cond,NULL)) == 0) { + /* + * If the condvar was statically allocated, properly + * initialize the tail queue. + */ + if (((*cond)->c_flags & COND_FLAGS_INITED) == 0) { + TAILQ_INIT(&(*cond)->c_queue); + (*cond)->c_flags |= COND_FLAGS_INITED; + } + + /* Lock the condition variable structure: */ _SPINLOCK(&(*cond)->lock); |