1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00

Return EPERM if mutex owner is not current thread but it tries to

unlock the mutex, old code confuses some programs when it returns EINVAL.

Noticed by: bland
This commit is contained in:
David Xu 2004-01-17 03:09:57 +00:00
parent cc3782cbc7
commit e4dcaa6ee9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=124606
2 changed files with 6 additions and 36 deletions

View File

@ -1001,12 +1001,7 @@ mutex_unlock_common(pthread_mutex_t *m, int add_reference)
* mutex:
*/
if ((*m)->m_owner != curthread)
/*
* Return an invalid argument error for no
* owner and a permission error otherwise:
*/
ret = (*m)->m_owner == NULL ? EINVAL : EPERM;
ret = EPERM;
else if (((*m)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
((*m)->m_count > 0))
/* Decrement the count: */
@ -1039,12 +1034,7 @@ mutex_unlock_common(pthread_mutex_t *m, int add_reference)
* mutex:
*/
if ((*m)->m_owner != curthread)
/*
* Return an invalid argument error for no
* owner and a permission error otherwise:
*/
ret = (*m)->m_owner == NULL ? EINVAL : EPERM;
ret = EPERM;
else if (((*m)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
((*m)->m_count > 0))
/* Decrement the count: */
@ -1096,12 +1086,7 @@ mutex_unlock_common(pthread_mutex_t *m, int add_reference)
* mutex:
*/
if ((*m)->m_owner != curthread)
/*
* Return an invalid argument error for no
* owner and a permission error otherwise:
*/
ret = (*m)->m_owner == NULL ? EINVAL : EPERM;
ret = EPERM;
else if (((*m)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
((*m)->m_count > 0))
/* Decrement the count: */

View File

@ -1001,12 +1001,7 @@ mutex_unlock_common(pthread_mutex_t *m, int add_reference)
* mutex:
*/
if ((*m)->m_owner != curthread)
/*
* Return an invalid argument error for no
* owner and a permission error otherwise:
*/
ret = (*m)->m_owner == NULL ? EINVAL : EPERM;
ret = EPERM;
else if (((*m)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
((*m)->m_count > 0))
/* Decrement the count: */
@ -1039,12 +1034,7 @@ mutex_unlock_common(pthread_mutex_t *m, int add_reference)
* mutex:
*/
if ((*m)->m_owner != curthread)
/*
* Return an invalid argument error for no
* owner and a permission error otherwise:
*/
ret = (*m)->m_owner == NULL ? EINVAL : EPERM;
ret = EPERM;
else if (((*m)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
((*m)->m_count > 0))
/* Decrement the count: */
@ -1096,12 +1086,7 @@ mutex_unlock_common(pthread_mutex_t *m, int add_reference)
* mutex:
*/
if ((*m)->m_owner != curthread)
/*
* Return an invalid argument error for no
* owner and a permission error otherwise:
*/
ret = (*m)->m_owner == NULL ? EINVAL : EPERM;
ret = EPERM;
else if (((*m)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
((*m)->m_count > 0))
/* Decrement the count: */