From b0eee6d57a5762d54162850afe1fbf034be05f47 Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Sat, 8 Aug 2020 16:34:49 -0400 Subject: [PATCH] Fix pointer truncation warning in ssl init inside tests --- indra/llcorehttp/examples/http_texture_load.cpp | 15 +++++++-------- indra/llcorehttp/tests/llcorehttp_test.cpp | 14 ++++++-------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/indra/llcorehttp/examples/http_texture_load.cpp b/indra/llcorehttp/examples/http_texture_load.cpp index c7376042b30..e8b806059d1 100644 --- a/indra/llcorehttp/examples/http_texture_load.cpp +++ b/indra/llcorehttp/examples/http_texture_load.cpp @@ -32,6 +32,7 @@ #if !defined(WIN32) #include <pthread.h> #endif +#include <thread> #include "linden_common.h" @@ -52,7 +53,7 @@ void init_curl(); void term_curl(); -void ssl_thread_id_callback(CRYPTO_THREADID*); +unsigned long ssl_thread_id(void); void ssl_locking_callback(int mode, int type, const char * file, int line); void usage(std::ostream & out); @@ -624,7 +625,7 @@ void init_curl() } CRYPTO_set_locking_callback(ssl_locking_callback); - CRYPTO_THREADID_set_callback(ssl_thread_id_callback); + CRYPTO_set_id_callback(&ssl_thread_id); } } @@ -640,13 +641,11 @@ void term_curl() } -void ssl_thread_id_callback(CRYPTO_THREADID* pthreadid) +//static +unsigned long ssl_thread_id(void) { -#if defined(WIN32) - CRYPTO_THREADID_set_pointer(pthreadid, GetCurrentThread()); -#else - CRYPTO_THREADID_set_pointer(pthreadid, pthread_self()); -#endif + // std::thread::id is very deliberately opaque, but we can hash it + return std::hash<std::thread::id>()(std::this_thread::get_id()); } diff --git a/indra/llcorehttp/tests/llcorehttp_test.cpp b/indra/llcorehttp/tests/llcorehttp_test.cpp index 362b2309eef..4c666e232bd 100755 --- a/indra/llcorehttp/tests/llcorehttp_test.cpp +++ b/indra/llcorehttp/tests/llcorehttp_test.cpp @@ -53,7 +53,7 @@ #include "llproxy.h" #include "llcleanup.h" -void ssl_thread_id_callback(CRYPTO_THREADID*); +unsigned long ssl_thread_id(void); void ssl_locking_callback(int mode, int type, const char * file, int line); #if 0 // lltut provides main and runner @@ -98,7 +98,7 @@ void init_curl() } CRYPTO_set_locking_callback(ssl_locking_callback); - CRYPTO_THREADID_set_callback(ssl_thread_id_callback); + CRYPTO_set_id_callback(&ssl_thread_id); } LLProxy::getInstance(); @@ -118,13 +118,11 @@ void term_curl() } -void ssl_thread_id_callback(CRYPTO_THREADID* pthreadid) +//static +unsigned long ssl_thread_id(void) { -#if defined(WIN32) - CRYPTO_THREADID_set_pointer(pthreadid, GetCurrentThread()); -#else - CRYPTO_THREADID_set_pointer(pthreadid, pthread_self()); -#endif + // std::thread::id is very deliberately opaque, but we can hash it + return std::hash<LLThread::id_t>()(LLThread::currentID()); } -- GitLab