From d4f9e0b3642a81d07c95302cd9aa0dcaf7de1a05 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 16 Mar 2011 16:25:00 -0400 Subject: correct error returns for error-checking mutexes --- src/thread/pthread_mutex_lock.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/thread/pthread_mutex_lock.c') diff --git a/src/thread/pthread_mutex_lock.c b/src/thread/pthread_mutex_lock.c index 15ede3f5..82556141 100644 --- a/src/thread/pthread_mutex_lock.c +++ b/src/thread/pthread_mutex_lock.c @@ -3,7 +3,11 @@ int pthread_mutex_lock(pthread_mutex_t *m) { int r; - while ((r=pthread_mutex_trylock(m)) == EBUSY) + while ((r=pthread_mutex_trylock(m)) == EBUSY) { + if (m->_m_type == PTHREAD_MUTEX_ERRORCHECK + && m->_m_owner == pthread_self()->tid) + return EDEADLK; __wait(&m->_m_lock, &m->_m_waiters, 1, 0); + } return r; } -- cgit v1.2.1