summaryrefslogtreecommitdiff
path: root/indra/llcorehttp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2021-06-08 05:06:21 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2021-06-08 05:06:21 +0300
commit0a745b47880fb16b1db8cd3327377a383dbfe6a8 (patch)
treee96e11b0083858ce6f70d67f3ea818c13bc43b29 /indra/llcorehttp
parent4cec2d689f9a7d1791f7ea3933cc1cdc59e972ab (diff)
Revert "Merge branch 'DRTVWR-520-apple-notarization' into DRTVWR-540-maint"
This reverts commit 681298dd726b2d00910fe71646147fadd1aba980, reversing changes made to 323f41f4892248762fc8505d8df17d70bd833cf3.
Diffstat (limited to 'indra/llcorehttp')
-rw-r--r--indra/llcorehttp/CMakeLists.txt1
-rw-r--r--indra/llcorehttp/httpcommon.cpp55
2 files changed, 56 insertions, 0 deletions
diff --git a/indra/llcorehttp/CMakeLists.txt b/indra/llcorehttp/CMakeLists.txt
index d90d148ee6..240ea2da83 100644
--- a/indra/llcorehttp/CMakeLists.txt
+++ b/indra/llcorehttp/CMakeLists.txt
@@ -176,6 +176,7 @@ if (DARWIN)
set(copy_dylibs
libapr-1.0.dylib
libaprutil-1.0.dylib
+ libexception_handler.dylib
libnghttp2*.dylib
liburiparser*.dylib
${EXPAT_COPY}
diff --git a/indra/llcorehttp/httpcommon.cpp b/indra/llcorehttp/httpcommon.cpp
index bbf23a6d70..e37a38b05f 100644
--- a/indra/llcorehttp/httpcommon.cpp
+++ b/indra/llcorehttp/httpcommon.cpp
@@ -23,6 +23,13 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
+#if LL_WINDOWS
+#define SAFE_SSL 1
+#elif LL_DARWIN
+#define SAFE_SSL 1
+#else
+#define SAFE_SSL 1
+#endif
#include "linden_common.h" // Modifies curl/curl.h interfaces
#include "httpcommon.h"
@@ -31,6 +38,10 @@
#include <curl/curl.h>
#include <string>
#include <sstream>
+#if SAFE_SSL
+#include <openssl/crypto.h>
+#include <functional> // std::hash
+#endif
namespace LLCore
@@ -337,6 +348,34 @@ void deallocateEasyCurl(CURL *curlp)
}
+#if SAFE_SSL
+//static
+void ssl_locking_callback(int mode, int type, const char *file, int line)
+{
+ if (type >= sSSLMutex.size())
+ {
+ LL_WARNS() << "Attempt to get unknown MUTEX in SSL Lock." << LL_ENDL;
+ }
+
+ if (mode & CRYPTO_LOCK)
+ {
+ sSSLMutex[type]->lock();
+ }
+ else
+ {
+ sSSLMutex[type]->unlock();
+ }
+}
+
+//static
+unsigned long ssl_thread_id(void)
+{
+ // std::thread::id is very deliberately opaque, but we can hash it
+ return std::hash<LLThread::id_t>()(LLThread::currentID());
+}
+#endif
+
+
}
void initialize()
@@ -348,11 +387,27 @@ void initialize()
check_curl_code(code, CURL_GLOBAL_ALL);
+#if SAFE_SSL
+ S32 mutex_count = CRYPTO_num_locks();
+ for (S32 i = 0; i < mutex_count; i++)
+ {
+ sSSLMutex.push_back(LLMutex_ptr(new LLMutex()));
+ }
+ CRYPTO_set_id_callback(&ssl_thread_id);
+ CRYPTO_set_locking_callback(&ssl_locking_callback);
+#endif
+
}
void cleanup()
{
+#if SAFE_SSL
+ CRYPTO_set_id_callback(NULL);
+ CRYPTO_set_locking_callback(NULL);
+ sSSLMutex.clear();
+#endif
+
curl_global_cleanup();
}