aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2018-08-29 20:50:05 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2018-08-29 20:50:05 -0400
commitbc1667791eedfe9d77d56dd9014e26481f571ff5 (patch)
tree3a428e9a0cc3ce0a733947ea0b4300f524602bf0 /src
parent3d0f333deb4ffbc0d05ea096c57d090e46222fe3 (diff)
downloadcryptography-bc1667791eedfe9d77d56dd9014e26481f571ff5.tar.gz
cryptography-bc1667791eedfe9d77d56dd9014e26481f571ff5.tar.bz2
cryptography-bc1667791eedfe9d77d56dd9014e26481f571ff5.zip
1.1.0 locks (#4420)
* Do conditional compiling of Cryptography_setup_ssl_threads * Check Cryptography_HAS_LOCKING_CALLBACKS before initing static locks Check if compiling and initing locking callbacks is necessary PEP8 fix * Make test_crypto_lock_init more complete
Diffstat (limited to 'src')
-rw-r--r--src/_cffi_src/openssl/callbacks.py5
-rw-r--r--src/cryptography/hazmat/bindings/openssl/_conditional.py1
-rw-r--r--src/cryptography/hazmat/bindings/openssl/binding.py3
3 files changed, 7 insertions, 2 deletions
diff --git a/src/_cffi_src/openssl/callbacks.py b/src/_cffi_src/openssl/callbacks.py
index 13c4e10c..75c62016 100644
--- a/src/_cffi_src/openssl/callbacks.py
+++ b/src/_cffi_src/openssl/callbacks.py
@@ -47,6 +47,7 @@ CUSTOMIZATIONS = """
using CPython APIs by Armin Rigo of the PyPy project.
*/
+#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_110
#ifdef _WIN32
typedef CRITICAL_SECTION Cryptography_mutex;
static __inline void cryptography_mutex_init(Cryptography_mutex *mutex) {
@@ -80,7 +81,6 @@ static inline void cryptography_mutex_unlock(Cryptography_mutex *mutex) {
#endif
-
static unsigned int _ssl_locks_count = 0;
static Cryptography_mutex *_ssl_locks = NULL;
@@ -135,6 +135,9 @@ int Cryptography_setup_ssl_threads(void) {
}
return 1;
}
+#else
+int (*Cryptography_setup_ssl_threads)(void) = NULL;
+#endif
typedef struct {
char *password;
diff --git a/src/cryptography/hazmat/bindings/openssl/_conditional.py b/src/cryptography/hazmat/bindings/openssl/_conditional.py
index 6cfd29fc..f477f6ab 100644
--- a/src/cryptography/hazmat/bindings/openssl/_conditional.py
+++ b/src/cryptography/hazmat/bindings/openssl/_conditional.py
@@ -143,6 +143,7 @@ def cryptography_has_locking_callbacks():
"CRYPTO_READ",
"CRYPTO_LOCK_SSL",
"CRYPTO_lock",
+ "Cryptography_setup_ssl_threads",
]
diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py
index 81cf547a..ec74d4cf 100644
--- a/src/cryptography/hazmat/bindings/openssl/binding.py
+++ b/src/cryptography/hazmat/bindings/openssl/binding.py
@@ -140,7 +140,8 @@ class Binding(object):
# the setup for this.
__import__("_ssl")
- if cls.lib.CRYPTO_get_locking_callback() != cls.ffi.NULL:
+ if (not cls.lib.Cryptography_HAS_LOCKING_CALLBACKS or
+ cls.lib.CRYPTO_get_locking_callback() != cls.ffi.NULL):
return
# If nothing else has setup a locking callback already, we set up