summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2018-09-04 21:28:38 -0400
committerRich Felker <dalias@aerifal.cx>2018-09-04 21:28:38 -0400
commit4e4a162d9af283cf71f7310c497672e0c2b8ca3b (patch)
tree4f8d40cad0374520d9d31f14793bb33cd5e2fc1e /src
parent4fb273bd4002b37d7e149e077974bc22e2bc4e26 (diff)
downloadmusl-4e4a162d9af283cf71f7310c497672e0c2b8ca3b.tar.gz
musl-4e4a162d9af283cf71f7310c497672e0c2b8ca3b.tar.bz2
musl-4e4a162d9af283cf71f7310c497672e0c2b8ca3b.tar.xz
musl-4e4a162d9af283cf71f7310c497672e0c2b8ca3b.zip
in pthread_mutex_trylock, EBUSY out more directly when possible
avoid gratuitously setting up and tearing down the robust list pending slot.
Diffstat (limited to 'src')
-rw-r--r--src/thread/pthread_mutex_trylock.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/thread/pthread_mutex_trylock.c b/src/thread/pthread_mutex_trylock.c
index 54876a61..783ca0c4 100644
--- a/src/thread/pthread_mutex_trylock.c
+++ b/src/thread/pthread_mutex_trylock.c
@@ -15,6 +15,7 @@ int __pthread_mutex_trylock_owner(pthread_mutex_t *m)
return 0;
}
if (own == 0x7fffffff) return ENOTRECOVERABLE;
+ if (own && (!(own & 0x40000000) || !(type & 4))) return EBUSY;
if (m->_m_type & 128) {
if (!self->robust_list.off) {
@@ -25,8 +26,7 @@ int __pthread_mutex_trylock_owner(pthread_mutex_t *m)
self->robust_list.pending = &m->_m_next;
}
- if ((own && (!(own & 0x40000000) || !(type & 4)))
- || a_cas(&m->_m_lock, old, tid) != old) {
+ if (a_cas(&m->_m_lock, old, tid) != old) {
self->robust_list.pending = 0;
return EBUSY;
}