Skip to content

Commit

Permalink
Merge pull request libevent#38 from NathanFrench/ssl_thread_updates
Browse files Browse the repository at this point in the history
Update OpenSSL example to reflect newer versions
  • Loading branch information
widgetii committed Dec 10, 2022
2 parents 68b62c7 + 62d65d7 commit cdb24e8
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion examples_R6a/R6a_ssl_lock_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,28 @@
pthread_mutex_t * ssl_locks;
int ssl_num_locks;

#ifndef WIN32
#define _SSLtid (unsigned long)pthread_self()
#else
#define _SSLtid pthread_self().p
#endif

/* Implements a thread-ID function as requied by openssl */
#if OPENSSL_VERSION_NUMBER < 0x10000000L
static unsigned long
get_thread_id_cb(void)
{
return (unsigned long)pthread_self();
return _SSLtid;
}

#else

static void
get_thread_id_cb(CRYPTO_THREADID *id)
{
CRYPTO_THREADID_set_numeric(id, _SSLtid);
}
#endif

static void
thread_lock_cb(int mode, int which, const char * f, int l)
Expand Down Expand Up @@ -47,7 +63,13 @@ init_ssl_locking(void)
pthread_mutex_init(&(ssl_locks[i]), NULL);
}


#if OPENSSL_VERSION_NUMBER < 0x10000000L
CRYPTO_set_id_callback(get_thread_id_cb);
#else
CRYPTO_THREADID_set_callback(get_thread_id_cb);
#endif

CRYPTO_set_locking_callback(thread_lock_cb);

return 0;
Expand Down

0 comments on commit cdb24e8

Please sign in to comment.