summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-08-19 15:36:29 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-08-19 15:36:29 (GMT)
commit10107813acc9a9c5895f4e00e264bc605443c538 (patch)
treeef38953180e613b3cff2253435fd1be4e73e316c /Modules
parentf65d454a5e8355663c84589b5c6b347e3552e9e5 (diff)
downloadcpython-10107813acc9a9c5895f4e00e264bc605443c538.zip
cpython-10107813acc9a9c5895f4e00e264bc605443c538.tar.gz
cpython-10107813acc9a9c5895f4e00e264bc605443c538.tar.bz2
Issue #18777: The ssl module now uses the new CRYPTO_THREADID API of
OpenSSL 1.0.0+ instead of the deprecated CRYPTO id callback function.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ssl.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 55c3155..b3eb6ec 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -1649,9 +1649,21 @@ static PyMethodDef PySSL_methods[] = {
static PyThread_type_lock *_ssl_locks = NULL;
-static unsigned long _ssl_thread_id_function (void) {
+#if OPENSSL_VERSION_NUMBER >= 0x10000000
+/* use new CRYPTO_THREADID API. */
+static void
+_ssl_threadid_callback(CRYPTO_THREADID *id)
+{
+ CRYPTO_THREADID_set_numeric(id,
+ (unsigned long)PyThread_get_thread_ident());
+}
+#else
+/* deprecated CRYPTO_set_id_callback() API. */
+static unsigned long
+_ssl_thread_id_function (void) {
return PyThread_get_thread_ident();
}
+#endif
static void _ssl_thread_locking_function (int mode, int n, const char *file, int line) {
/* this function is needed to perform locking on shared data
@@ -1702,7 +1714,11 @@ static int _setup_ssl_threads(void) {
}
}
CRYPTO_set_locking_callback(_ssl_thread_locking_function);
+#if OPENSSL_VERSION_NUMBER >= 0x10000000
+ CRYPTO_THREADID_set_callback(_ssl_threadid_callback);
+#else
CRYPTO_set_id_callback(_ssl_thread_id_function);
+#endif
}
return 1;
}