diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-03-16 16:25:00 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-03-16 16:25:00 -0400 |
commit | d4f9e0b3642a81d07c95302cd9aa0dcaf7de1a05 (patch) | |
tree | 8bb9017678027a5f7c0b461fc9e246d34d0ebd1d /src/thread/pthread_mutex_lock.c | |
parent | 29fae65780f4c5ccda3758828da7a83073297ccc (diff) | |
download | musl-d4f9e0b3642a81d07c95302cd9aa0dcaf7de1a05.tar.gz musl-d4f9e0b3642a81d07c95302cd9aa0dcaf7de1a05.tar.bz2 musl-d4f9e0b3642a81d07c95302cd9aa0dcaf7de1a05.tar.xz musl-d4f9e0b3642a81d07c95302cd9aa0dcaf7de1a05.zip |
correct error returns for error-checking mutexes
Diffstat (limited to 'src/thread/pthread_mutex_lock.c')
-rw-r--r-- | src/thread/pthread_mutex_lock.c | 6 |
1 files changed, 5 insertions, 1 deletions
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; } |