From: Alan T. DeKok Date: Mon, 20 Nov 2017 18:53:28 +0000 (-0500) Subject: set THREADID callbacks instead of global callbacks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85df50c4012e30bf27ce3074772da54ddcbd35ac;p=thirdparty%2Ffreeradius-server.git set THREADID callbacks instead of global callbacks when we have them. --- diff --git a/src/lib/tls/global.c b/src/lib/tls/global.c index f1ce17139d9..0cb9e5e983e 100644 --- a/src/lib/tls/global.c +++ b/src/lib/tls/global.c @@ -128,6 +128,23 @@ static unsigned long _thread_id(void) return ret; } +/* + * Use preprocessor magic to get the right function and argument + * to use. This avoids ifdef's through the rest of the code. + */ +#if OPENSSL_VERSION_NUMBER < 0x10000000L +#define ssl_id_function _thread_id +#define set_id_callback CRYPTO_set_id_callback + +#else +static void ssl_id_function(CRYPTO_THREADID *id) +{ + CRYPTO_THREADID_set_numeric(id, _thread_id()); +} +#define set_id_callback CRYPTO_THREADID_set_callback +#endif + + static void _global_mutex(int mode, int n, UNUSED char const *file, UNUSED int line) { if (mode & CRYPTO_LOCK) { @@ -236,7 +253,7 @@ static pthread_mutex_t *global_mutexes_init(TALLOC_CTX *ctx) */ while (i < CRYPTO_num_locks()) SETUP_CRYPTO_LOCK; - CRYPTO_set_id_callback(_thread_id); + set_id_callback(ssl_id_function); CRYPTO_set_locking_callback(_global_mutex); return mutexes;