1
0
mirror of synced 2025-04-21 22:25:55 +03:00

Fixed build errors

This commit is contained in:
yhirose 2019-07-22 06:58:05 -04:00
parent 7267b3f3e2
commit dd20e4d418

View File

@ -2482,29 +2482,30 @@ read_and_close_socket_ssl(socket_t sock, size_t keep_alive_max_count,
} }
#if OPENSSL_VERSION_NUMBER < 0x10100000L #if OPENSSL_VERSION_NUMBER < 0x10100000L
static std::shared_ptr<std::vector<std::mutex>> openSSL_locks_;
class SSLThreadLocks { class SSLThreadLocks {
public: public:
SSLThreadLocks() { SSLThreadLocks() {
openSSL_locks_ =
std::make_shared<std::vector<std::mutex>>(CRYPTO_num_locks());
CRYPTO_set_locking_callback(locking_callback); CRYPTO_set_locking_callback(locking_callback);
} }
~SSLThreadLocks() { ~SSLThreadLocks() { CRYPTO_set_locking_callback(nullptr); }
CRYPTO_set_locking_callback(nullptr);
}
private: private:
static void locking_callback(int mode, int type, const char * /*file*/, int /*line*/) { static void locking_callback(int mode, int type, const char * /*file*/,
int /*line*/) {
auto &locks = *openSSL_locks_;
if (mode & CRYPTO_LOCK) { if (mode & CRYPTO_LOCK) {
locks_[type].lock(); locks[type].lock();
} else { } else {
locks_[type].unlock(); locks[type].unlock();
} }
} }
static std::vector<std::mutex> locks_;
}; };
std::vector<std::mutex> SSLThreadLocks::locks_(CRYPTO_num_locks());
#endif #endif
class SSLInit { class SSLInit {