[Python-checkins] cpython (merge 3.3 -> default): Issue #18777: The ssl module now uses the new CRYPTO_THREADID API of

christian.heimes python-checkins at python.org
Mon Aug 19 17:37:19 CEST 2013


http://hg.python.org/cpython/rev/28e68f4807a2
changeset:   85264:28e68f4807a2
parent:      85262:a887596b841f
parent:      85263:f967ded6f9dd
user:        Christian Heimes <christian at cheimes.de>
date:        Mon Aug 19 17:36:39 2013 +0200
summary:
  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.

files:
  Misc/NEWS      |   3 +++
  Modules/_ssl.c |  18 +++++++++++++++++-
  2 files changed, 20 insertions(+), 1 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -34,6 +34,9 @@
 Library
 -------
 
+- 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.
+
 - Issue #18768: Correct doc string of RAND_edg(). Patch by Vajrasky Kok.
 
 - Issue #18178: Fix ctypes on BSD. dlmalloc.c was compiled twice which broke
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -3136,9 +3136,21 @@
 
 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) {
@@ -3191,7 +3203,11 @@
             }
         }
         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;
 }

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list