mirror of git://sourceware.org/git/glibc.git
(__pthread_mutex_lock): Always initialize __m_owner. (__pthread_mutex_trylock): Likewise. (__pthread_mutex_unlock): Always clear __m_owner.
This commit is contained in:
parent
5a0ca44d63
commit
9de74ebf76
|
|
@ -50,6 +50,7 @@ int __pthread_mutex_trylock(pthread_mutex_t * mutex)
|
||||||
switch(mutex->__m_kind) {
|
switch(mutex->__m_kind) {
|
||||||
case PTHREAD_MUTEX_FAST_NP:
|
case PTHREAD_MUTEX_FAST_NP:
|
||||||
retcode = __pthread_trylock(&mutex->__m_lock);
|
retcode = __pthread_trylock(&mutex->__m_lock);
|
||||||
|
mutex->__m_owner = thread_self();
|
||||||
return retcode;
|
return retcode;
|
||||||
case PTHREAD_MUTEX_RECURSIVE_NP:
|
case PTHREAD_MUTEX_RECURSIVE_NP:
|
||||||
self = thread_self();
|
self = thread_self();
|
||||||
|
|
@ -77,12 +78,12 @@ strong_alias (__pthread_mutex_trylock, pthread_mutex_trylock)
|
||||||
|
|
||||||
int __pthread_mutex_lock(pthread_mutex_t * mutex)
|
int __pthread_mutex_lock(pthread_mutex_t * mutex)
|
||||||
{
|
{
|
||||||
pthread_descr self;
|
pthread_descr self = thread_self();
|
||||||
|
|
||||||
switch(mutex->__m_kind) {
|
switch(mutex->__m_kind) {
|
||||||
case PTHREAD_MUTEX_FAST_NP:
|
case PTHREAD_MUTEX_FAST_NP:
|
||||||
__pthread_lock(&mutex->__m_lock, NULL);
|
__pthread_lock(&mutex->__m_lock, NULL);
|
||||||
return 0;
|
break;
|
||||||
case PTHREAD_MUTEX_RECURSIVE_NP:
|
case PTHREAD_MUTEX_RECURSIVE_NP:
|
||||||
self = thread_self();
|
self = thread_self();
|
||||||
if (mutex->__m_owner == self) {
|
if (mutex->__m_owner == self) {
|
||||||
|
|
@ -90,18 +91,18 @@ int __pthread_mutex_lock(pthread_mutex_t * mutex)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
__pthread_lock(&mutex->__m_lock, self);
|
__pthread_lock(&mutex->__m_lock, self);
|
||||||
mutex->__m_owner = self;
|
|
||||||
mutex->__m_count = 0;
|
mutex->__m_count = 0;
|
||||||
return 0;
|
break;
|
||||||
case PTHREAD_MUTEX_ERRORCHECK_NP:
|
case PTHREAD_MUTEX_ERRORCHECK_NP:
|
||||||
self = thread_self();
|
self = thread_self();
|
||||||
if (mutex->__m_owner == self) return EDEADLK;
|
if (mutex->__m_owner == self) return EDEADLK;
|
||||||
__pthread_lock(&mutex->__m_lock, self);
|
__pthread_lock(&mutex->__m_lock, self);
|
||||||
mutex->__m_owner = self;
|
break;
|
||||||
return 0;
|
|
||||||
default:
|
default:
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
mutex->__m_owner = self;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
strong_alias (__pthread_mutex_lock, pthread_mutex_lock)
|
strong_alias (__pthread_mutex_lock, pthread_mutex_lock)
|
||||||
|
|
||||||
|
|
@ -110,6 +111,7 @@ int __pthread_mutex_unlock(pthread_mutex_t * mutex)
|
||||||
switch (mutex->__m_kind) {
|
switch (mutex->__m_kind) {
|
||||||
case PTHREAD_MUTEX_FAST_NP:
|
case PTHREAD_MUTEX_FAST_NP:
|
||||||
__pthread_unlock(&mutex->__m_lock);
|
__pthread_unlock(&mutex->__m_lock);
|
||||||
|
mutex->__m_owner = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
case PTHREAD_MUTEX_RECURSIVE_NP:
|
case PTHREAD_MUTEX_RECURSIVE_NP:
|
||||||
if (mutex->__m_count > 0) {
|
if (mutex->__m_count > 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue