diff options
Diffstat (limited to 'nptl/pthread_mutex_unlock.c')
-rw-r--r-- | nptl/pthread_mutex_unlock.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c index 3595585a84..975127d2b2 100644 --- a/nptl/pthread_mutex_unlock.c +++ b/nptl/pthread_mutex_unlock.c @@ -30,23 +30,19 @@ __pthread_mutex_unlock (mutex) { case PTHREAD_MUTEX_RECURSIVE_NP: /* Recursive mutex. */ - if (mutex->__data.__owner != THREAD_SELF) + if (mutex->__data.__owner != THREAD_ID) return EPERM; if (--mutex->__data.__count != 0) /* We still hold the mutex. */ return 0; - - mutex->__data.__owner = NULL; break; case PTHREAD_MUTEX_ERRORCHECK_NP: /* Error checking mutex. */ - if (mutex->__data.__owner != THREAD_SELF + if (mutex->__data.__owner != THREAD_ID || ! lll_mutex_islocked (mutex->__data.__lock)) return EPERM; - - mutex->__data.__owner = NULL; break; default: @@ -57,6 +53,9 @@ __pthread_mutex_unlock (mutex) break; } + /* Always reset the owner field. */ + mutex->__data.__owner = NULL; + /* Unlock. */ lll_mutex_unlock (mutex->__data.__lock); |