Fix a problem with static initialisation of mutexes and condition
variables. Submitted by: Dan Eischen <eischen@vigrid.com>
This commit is contained in:
parent
3162b42ed3
commit
46db87a1e4
@ -210,7 +210,8 @@ struct pthread_mutex {
|
||||
*/
|
||||
#define PTHREAD_MUTEX_STATIC_INITIALIZER \
|
||||
{ PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, TAILQ_INITIALIZER, \
|
||||
NULL, { NULL }, MUTEX_FLAGS_INITED, 0, 0, 0, TAILQ_INITIALIZER }
|
||||
NULL, { NULL }, 0, 0, 0, 0, TAILQ_INITIALIZER, \
|
||||
_SPINLOCK_INITIALIZER }
|
||||
|
||||
struct pthread_mutex_attr {
|
||||
enum pthread_mutextype m_type;
|
||||
@ -257,7 +258,7 @@ struct pthread_cond_attr {
|
||||
*/
|
||||
#define PTHREAD_COND_STATIC_INITIALIZER \
|
||||
{ COND_TYPE_FAST, PTHREAD_QUEUE_INITIALIZER, NULL, NULL \
|
||||
COND_FLAGS_INITED }
|
||||
0, _SPINLOCK_INITIALIZER }
|
||||
|
||||
/*
|
||||
* Cleanup definitions.
|
||||
|
@ -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);
|
||||
|
||||
|
@ -221,6 +221,15 @@ pthread_mutex_trylock(pthread_mutex_t * mutex)
|
||||
* initialization:
|
||||
*/
|
||||
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
|
||||
@ -351,6 +360,15 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
|
||||
* initialization:
|
||||
*/
|
||||
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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -221,6 +221,15 @@ pthread_mutex_trylock(pthread_mutex_t * mutex)
|
||||
* initialization:
|
||||
*/
|
||||
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
|
||||
@ -351,6 +360,15 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
|
||||
* initialization:
|
||||
*/
|
||||
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
|
||||
|
@ -210,7 +210,8 @@ struct pthread_mutex {
|
||||
*/
|
||||
#define PTHREAD_MUTEX_STATIC_INITIALIZER \
|
||||
{ PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, TAILQ_INITIALIZER, \
|
||||
NULL, { NULL }, MUTEX_FLAGS_INITED, 0, 0, 0, TAILQ_INITIALIZER }
|
||||
NULL, { NULL }, 0, 0, 0, 0, TAILQ_INITIALIZER, \
|
||||
_SPINLOCK_INITIALIZER }
|
||||
|
||||
struct pthread_mutex_attr {
|
||||
enum pthread_mutextype m_type;
|
||||
@ -257,7 +258,7 @@ struct pthread_cond_attr {
|
||||
*/
|
||||
#define PTHREAD_COND_STATIC_INITIALIZER \
|
||||
{ COND_TYPE_FAST, PTHREAD_QUEUE_INITIALIZER, NULL, NULL \
|
||||
COND_FLAGS_INITED }
|
||||
0, _SPINLOCK_INITIALIZER }
|
||||
|
||||
/*
|
||||
* Cleanup definitions.
|
||||
|
@ -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);
|
||||
|
||||
|
@ -221,6 +221,15 @@ pthread_mutex_trylock(pthread_mutex_t * mutex)
|
||||
* initialization:
|
||||
*/
|
||||
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
|
||||
@ -351,6 +360,15 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
|
||||
* initialization:
|
||||
*/
|
||||
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
|
||||
|
@ -210,7 +210,8 @@ struct pthread_mutex {
|
||||
*/
|
||||
#define PTHREAD_MUTEX_STATIC_INITIALIZER \
|
||||
{ PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, TAILQ_INITIALIZER, \
|
||||
NULL, { NULL }, MUTEX_FLAGS_INITED, 0, 0, 0, TAILQ_INITIALIZER }
|
||||
NULL, { NULL }, 0, 0, 0, 0, TAILQ_INITIALIZER, \
|
||||
_SPINLOCK_INITIALIZER }
|
||||
|
||||
struct pthread_mutex_attr {
|
||||
enum pthread_mutextype m_type;
|
||||
@ -257,7 +258,7 @@ struct pthread_cond_attr {
|
||||
*/
|
||||
#define PTHREAD_COND_STATIC_INITIALIZER \
|
||||
{ COND_TYPE_FAST, PTHREAD_QUEUE_INITIALIZER, NULL, NULL \
|
||||
COND_FLAGS_INITED }
|
||||
0, _SPINLOCK_INITIALIZER }
|
||||
|
||||
/*
|
||||
* Cleanup definitions.
|
||||
|
Loading…
Reference in New Issue
Block a user