about summary refs log tree commit diff
path: root/src/thread/pthread_mutex_timedlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread/pthread_mutex_timedlock.c')
-rw-r--r--src/thread/pthread_mutex_timedlock.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/thread/pthread_mutex_timedlock.c b/src/thread/pthread_mutex_timedlock.c
index 849febb7..2a959d25 100644
--- a/src/thread/pthread_mutex_timedlock.c
+++ b/src/thread/pthread_mutex_timedlock.c
@@ -9,9 +9,10 @@ int pthread_mutex_timedlock(pthread_mutex_t *restrict m, const struct timespec *
 	int r, t, priv = (m->_m_type & 128) ^ 128;
 
 	while ((r=pthread_mutex_trylock(m)) == EBUSY) {
-		if (!(r=m->_m_lock) || (r&0x40000000)) continue;
+		if (!(r=m->_m_lock) || ((r&0x40000000) && (m->_m_type&4)))
+			continue;
 		if ((m->_m_type&3) == PTHREAD_MUTEX_ERRORCHECK
-		 && (r&0x1fffffff) == __pthread_self()->tid)
+		 && (r&0x7fffffff) == __pthread_self()->tid)
 			return EDEADLK;
 
 		a_inc(&m->_m_waiters);