summaryrefslogtreecommitdiff
path: root/locks/unix/thread_mutex.c
diff options
context:
space:
mode:
authorBrian Pane <brianp@apache.org>2002-04-28 03:21:24 +0000
committerBrian Pane <brianp@apache.org>2002-04-28 03:21:24 +0000
commitf267905b308878f08c69bb80e890977970b69eb6 (patch)
treea67757c3bf4ef768a40a6ba24a33be1541301a62 /locks/unix/thread_mutex.c
parentdeba81f70ffe2b3540a8c9bd8f28020972ca9162 (diff)
downloadapr-f267905b308878f08c69bb80e890977970b69eb6.tar.gz
Optimization: rearranged the mutex lock/unlock code to
eliminate a conditional branch on platforms where PTHREAD_SETS_ERRNO is not defined (at present, this means everything except OS/390) git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@63307 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'locks/unix/thread_mutex.c')
-rw-r--r--locks/unix/thread_mutex.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/locks/unix/thread_mutex.c b/locks/unix/thread_mutex.c
index 78a7d8181..170e0b70a 100644
--- a/locks/unix/thread_mutex.c
+++ b/locks/unix/thread_mutex.c
@@ -143,19 +143,17 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex)
mutex->owner = apr_os_thread_current();
mutex->owner_ref = 1;
+ return rv;
}
else {
rv = pthread_mutex_lock(&mutex->mutex);
- if (rv) {
#ifdef PTHREAD_SETS_ERRNO
+ if (rv) {
rv = errno;
-#endif
- return rv;
}
-
+#endif
+ return rv;
}
-
- return rv;
}
APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex)
@@ -212,17 +210,17 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex)
memset(&mutex->owner, 0, sizeof mutex->owner);
mutex->owner_ref = 0;
+ return status;
}
else {
status = pthread_mutex_unlock(&mutex->mutex);
- if (status) {
#ifdef PTHREAD_SETS_ERRNO
+ if (status) {
status = errno;
-#endif
- return status;
}
+#endif
+ return status;
}
- return status;
}
APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex)