summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2010-10-27 04:19:07 +0000
committerdavidxu <davidxu@FreeBSD.org>2010-10-27 04:19:07 +0000
commitd60836560b70dc27168374f0b81dec9b77b09723 (patch)
tree13cf07e429ab2682e1b242f9d4279acdc884fb3b /lib/libthr
parent29be5dcd229fd8e554eb507fe7c8c400842967af (diff)
downloadFreeBSD-src-d60836560b70dc27168374f0b81dec9b77b09723.zip
FreeBSD-src-d60836560b70dc27168374f0b81dec9b77b09723.tar.gz
Remove locking and unlock in pthread_mutex_destroy, because
it can not fix race condition in application code, as a result, the problem described in PR threads/151767 is avoided.
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/thread/thr_mutex.c27
1 files changed, 2 insertions, 25 deletions
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index a83454a..29f91ec 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -257,10 +257,8 @@ _mutex_fork(struct pthread *curthread)
int
_pthread_mutex_destroy(pthread_mutex_t *mutex)
{
- struct pthread *curthread = _get_curthread();
pthread_mutex_t m;
- uint32_t id;
- int ret = 0;
+ int ret;
m = *mutex;
if (m < THR_MUTEX_DESTROYED) {
@@ -268,34 +266,13 @@ _pthread_mutex_destroy(pthread_mutex_t *mutex)
} else if (m == THR_MUTEX_DESTROYED) {
ret = EINVAL;
} else {
- id = TID(curthread);
-
- /*
- * Try to lock the mutex structure, we only need to
- * try once, if failed, the mutex is in used.
- */
- ret = _thr_umutex_trylock(&m->m_lock, id);
- if (ret)
- return (ret);
- /*
- * Check mutex other fields to see if this mutex is
- * in use. Mostly for prority mutex types, or there
- * are condition variables referencing it.
- */
if (m->m_owner != NULL || m->m_refcount != 0) {
- if (m->m_lock.m_flags & UMUTEX_PRIO_PROTECT)
- set_inherited_priority(curthread, m);
- _thr_umutex_unlock(&m->m_lock, id);
ret = EBUSY;
} else {
*mutex = THR_MUTEX_DESTROYED;
-
- if (m->m_lock.m_flags & UMUTEX_PRIO_PROTECT)
- set_inherited_priority(curthread, m);
- _thr_umutex_unlock(&m->m_lock, id);
-
MUTEX_ASSERT_NOT_OWNED(m);
free(m);
+ ret = 0;
}
}
OpenPOWER on IntegriCloud