Fix compilation without deprecated APIs in OpenSSL

Added a few implicit headers that don't get included anymore and switched
to OpenSSL 1.0.0's THREAD API when supported.

Close #1615
This commit is contained in:
Rosen Penev
2018-11-08 11:04:48 -08:00
committed by Alexey Sokolov
parent a31df2474b
commit dddcef52b9
3 changed files with 13 additions and 0 deletions

View File

@@ -46,9 +46,15 @@ static void locking_callback(int mode, int type, const char* file, int line) {
}
}
#if OPENSSL_VERSION_NUMBER >= 0x10000000
static void thread_id_callback(CRYPTO_THREADID *id) {
CRYPTO_THREADID_set_numeric(id, (unsigned long)pthread_self());
}
#else
static unsigned long thread_id_callback() {
return (unsigned long)pthread_self();
}
#endif
static CRYPTO_dynlock_value* dyn_create_callback(const char* file, int line) {
return (CRYPTO_dynlock_value*)new CMutex;
@@ -78,7 +84,11 @@ static void thread_setup() {
for (std::unique_ptr<CMutex>& mtx : lock_cs)
mtx = std::unique_ptr<CMutex>(new CMutex());
#if OPENSSL_VERSION_NUMBER >= 0x10000000
CRYPTO_THREADID_set_callback(&thread_id_callback);
#else
CRYPTO_set_id_callback(&thread_id_callback);
#endif
CRYPTO_set_locking_callback(&locking_callback);
CRYPTO_set_dynlock_create_callback(&dyn_create_callback);