diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2016-11-06 12:07:32 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2016-11-07 11:46:47 +0100 |
commit | 2dff359a331c5c9aab2435c470596b0fee7a502a (patch) | |
tree | 2274c371650f6201515e73623eb767da1e77ae3f /src/threads.c | |
parent | 3341f49a49a07cbce003e487ef24a2042e800f01 (diff) | |
download | libssh-2dff359a331c5c9aab2435c470596b0fee7a502a.tar.gz libssh-2dff359a331c5c9aab2435c470596b0fee7a502a.tar.xz libssh-2dff359a331c5c9aab2435c470596b0fee7a502a.zip |
threads: Use new API call for OpenSSL CRYPTO THREADID
BUG: https://red.libssh.org/issues/222
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/threads.c')
-rw-r--r-- | src/threads.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/threads.c b/src/threads.c index 7f3a304e..062c3b84 100644 --- a/src/threads.c +++ b/src/threads.c @@ -116,6 +116,15 @@ static void libcrypto_lock_callback(int mode, int i, const char *file, int line) } } +#ifdef HAVE_OPENSSL_CRYPTO_THREADID_SET_CALLBACK +static void libcrypto_THREADID_callback(CRYPTO_THREADID *id) +{ + unsigned long thread_id = (*user_callbacks->thread_id)(); + + CRYPTO_THREADID_set_numeric(id, thread_id); +} +#endif /* HAVE_OPENSSL_CRYPTO_THREADID_SET_CALLBACK */ + static int libcrypto_thread_init(void){ int n=CRYPTO_num_locks(); int i; @@ -127,8 +136,14 @@ static int libcrypto_thread_init(void){ for (i=0;i<n;++i){ user_callbacks->mutex_init(&libcrypto_mutexes[i]); } - CRYPTO_set_id_callback(user_callbacks->thread_id); - CRYPTO_set_locking_callback(libcrypto_lock_callback); + +#ifdef HAVE_OPENSSL_CRYPTO_THREADID_SET_CALLBACK + CRYPTO_THREADID_set_callback(libcrypto_THREADID_callback); +#else + CRYPTO_set_id_callback(user_callbacks->thread_id); +#endif + + CRYPTO_set_locking_callback(libcrypto_lock_callback); return SSH_OK; } |