From 5713f2b86725904279a0b5dcad91f52372f23e1d Mon Sep 17 00:00:00 2001 From: "irons.du" Date: Mon, 3 Jun 2024 21:27:50 +0800 Subject: [PATCH] Add `SSLHelper::InitThreadSafeSupport` for initialize the OpenSSL thread safe. --- include/brynet/net/SSLHelper.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/brynet/net/SSLHelper.hpp b/include/brynet/net/SSLHelper.hpp index f47a207..7863431 100644 --- a/include/brynet/net/SSLHelper.hpp +++ b/include/brynet/net/SSLHelper.hpp @@ -82,11 +82,16 @@ class SSLHelper : public brynet::base::NonCopyable, using Ptr = std::shared_ptr; #ifdef BRYNET_USE_OPENSSL - bool initSSL(const std::string& certificate, - const std::string& privatekey) + static void InitThreadSafeSupport() { std::call_once(initCryptoThreadSafeSupportOnceFlag, InitCryptoThreadSafeSupport); + } + + bool initSSL(const std::string& certificate, + const std::string& privatekey) + { + SSLHelper::InitThreadSafeSupport(); if (mOpenSSLCTX != nullptr) {