diff options
author | davidxu <davidxu@FreeBSD.org> | 2004-01-17 03:09:57 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2004-01-17 03:09:57 +0000 |
commit | 47933921d05e2c40de9144ea6dbb136f34390da8 (patch) | |
tree | a8e6248b52a3aaf5088a6fc7e11d963636eeaa3e /lib/libkse | |
parent | f9aac56ad7dea97108acd58f36d211e416fb0322 (diff) | |
download | FreeBSD-src-47933921d05e2c40de9144ea6dbb136f34390da8.zip FreeBSD-src-47933921d05e2c40de9144ea6dbb136f34390da8.tar.gz |
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
Diffstat (limited to 'lib/libkse')
-rw-r--r-- | lib/libkse/thread/thr_mutex.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/lib/libkse/thread/thr_mutex.c b/lib/libkse/thread/thr_mutex.c index 464bc39..1232f33 100644 --- a/lib/libkse/thread/thr_mutex.c +++ b/lib/libkse/thread/thr_mutex.c @@ -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: */ |