Lines 5-11
Link Here
|
5 |
#include <pythread.h> |
5 |
#include <pythread.h> |
6 |
#include <openssl/crypto.h> |
6 |
#include <openssl/crypto.h> |
7 |
|
7 |
|
8 |
#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L |
8 |
#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) |
9 |
#define CRYPTO_num_locks() (CRYPTO_NUM_LOCKS) |
9 |
#define CRYPTO_num_locks() (CRYPTO_NUM_LOCKS) |
10 |
static PyThread_type_lock lock_cs[CRYPTO_num_locks()]; |
10 |
static PyThread_type_lock lock_cs[CRYPTO_num_locks()]; |
11 |
static long lock_count[CRYPTO_num_locks()]; |
11 |
static long lock_count[CRYPTO_num_locks()]; |
Lines 13-19
static int thread_mode = 0;
Link Here
|
13 |
#endif |
13 |
#endif |
14 |
|
14 |
|
15 |
void threading_locking_callback(int mode, int type, const char *file, int line) { |
15 |
void threading_locking_callback(int mode, int type, const char *file, int line) { |
16 |
#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L |
16 |
#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) |
17 |
if (mode & CRYPTO_LOCK) { |
17 |
if (mode & CRYPTO_LOCK) { |
18 |
PyThread_acquire_lock(lock_cs[type], WAIT_LOCK); |
18 |
PyThread_acquire_lock(lock_cs[type], WAIT_LOCK); |
19 |
lock_count[type]++; |
19 |
lock_count[type]++; |
Lines 25-31
void threading_locking_callback(int mode, int type, const char *file, int line)
Link Here
|
25 |
} |
25 |
} |
26 |
|
26 |
|
27 |
unsigned long threading_id_callback(void) { |
27 |
unsigned long threading_id_callback(void) { |
28 |
#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L |
28 |
#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) |
29 |
return (unsigned long)PyThread_get_thread_ident(); |
29 |
return (unsigned long)PyThread_get_thread_ident(); |
30 |
#else |
30 |
#else |
31 |
return (unsigned long)0; |
31 |
return (unsigned long)0; |
Lines 35-41
unsigned long threading_id_callback(void) {
Link Here
|
35 |
|
35 |
|
36 |
%inline %{ |
36 |
%inline %{ |
37 |
void threading_init(void) { |
37 |
void threading_init(void) { |
38 |
#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L |
38 |
#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) |
39 |
int i; |
39 |
int i; |
40 |
if (!thread_mode) { |
40 |
if (!thread_mode) { |
41 |
for (i=0; i<CRYPTO_num_locks(); i++) { |
41 |
for (i=0; i<CRYPTO_num_locks(); i++) { |
Lines 50-56
void threading_init(void) {
Link Here
|
50 |
} |
50 |
} |
51 |
|
51 |
|
52 |
void threading_cleanup(void) { |
52 |
void threading_cleanup(void) { |
53 |
#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L |
53 |
#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) |
54 |
int i; |
54 |
int i; |
55 |
if (thread_mode) { |
55 |
if (thread_mode) { |
56 |
CRYPTO_set_locking_callback(NULL); |
56 |
CRYPTO_set_locking_callback(NULL); |