From 18c7ea8055cf733f168d2c74d7cc8523a360f5f1 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 17 Mar 2011 13:35:08 -0400 Subject: avoid function call to pthread_self in mutex unlock if the mutex was previously locked, we can assume pthread_self was already called at the time of locking, and thus that the thread pointer is initialized. --- src/thread/pthread_mutex_unlock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/thread/pthread_mutex_unlock.c') diff --git a/src/thread/pthread_mutex_unlock.c b/src/thread/pthread_mutex_unlock.c index 61a2b947..3733788d 100644 --- a/src/thread/pthread_mutex_unlock.c +++ b/src/thread/pthread_mutex_unlock.c @@ -3,7 +3,7 @@ int pthread_mutex_unlock(pthread_mutex_t *m) { if (m->_m_type != PTHREAD_MUTEX_NORMAL) { - if (m->_m_lock != pthread_self()->tid) + if (!m->_m_lock || m->_m_lock != __pthread_self()->tid) return EPERM; if (m->_m_type == PTHREAD_MUTEX_RECURSIVE && --m->_m_count) return 0; -- cgit v1.2.1