[openssl] master update
Matt Caswell
matt at openssl.org
Fri Feb 5 10:44:30 UTC 2021
The branch master has been updated
via e60147fe74c202ef3ce5d36115252b7c3c504cd7 (commit)
from 05f41859ddfff9b19f6599e545607f3d49630ce0 (commit)
- Log -----------------------------------------------------------------
commit e60147fe74c202ef3ce5d36115252b7c3c504cd7
Author: Rich Salz <rsalz at akamai.com>
Date: Thu Jan 21 12:32:27 2021 -0500
Don't make pthreads mutexes recursive.
Reviewed-by: Paul Dale <pauli at openssl.org>
Reviewed-by: Matt Caswell <matt at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13924)
-----------------------------------------------------------------------
Summary of changes:
crypto/threads_pthread.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c
index 22ba793161..68ec5dc1df 100644
--- a/crypto/threads_pthread.c
+++ b/crypto/threads_pthread.c
@@ -51,12 +51,15 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
return NULL;
}
+ /*
+ * We don't use recursive mutexes, but try to catch errors if we do.
+ */
pthread_mutexattr_init(&attr);
- #if defined(__TANDEM) && defined(_SPT_MODEL_)
- pthread_mutexattr_setkind_np(&attr,MUTEX_RECURSIVE_NP);
- #else
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
- #endif
+# if defined(NDEBUG) && defined(PTHREAD_MUTEX_ERRORCHECK)
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
+# else
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
+# endif
if (pthread_mutex_init(lock, &attr) != 0) {
pthread_mutexattr_destroy(&attr);
@@ -76,8 +79,10 @@ int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)
if (pthread_rwlock_rdlock(lock) != 0)
return 0;
# else
- if (pthread_mutex_lock(lock) != 0)
+ if (pthread_mutex_lock(lock) != 0) {
+ assert(errno != EDEADLK && errno != EBUSY);
return 0;
+ }
# endif
return 1;
@@ -89,8 +94,10 @@ int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
if (pthread_rwlock_wrlock(lock) != 0)
return 0;
# else
- if (pthread_mutex_lock(lock) != 0)
+ if (pthread_mutex_lock(lock) != 0) {
+ assert(errno != EDEADLK && errno != EBUSY);
return 0;
+ }
# endif
return 1;
@@ -102,8 +109,10 @@ int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock)
if (pthread_rwlock_unlock(lock) != 0)
return 0;
# else
- if (pthread_mutex_unlock(lock) != 0)
+ if (pthread_mutex_unlock(lock) != 0) {
+ assert(errno != EPERM);
return 0;
+ }
# endif
return 1;
More information about the openssl-commits
mailing list