mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 14:29:10 -07:00
Fixed build errors
This commit is contained in:
parent
7267b3f3e2
commit
dd20e4d418
1 changed files with 10 additions and 9 deletions
19
httplib.h
19
httplib.h
|
@ -2482,29 +2482,30 @@ read_and_close_socket_ssl(socket_t sock, size_t keep_alive_max_count,
|
|||
}
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
static std::shared_ptr<std::vector<std::mutex>> openSSL_locks_;
|
||||
|
||||
class SSLThreadLocks {
|
||||
public:
|
||||
SSLThreadLocks() {
|
||||
openSSL_locks_ =
|
||||
std::make_shared<std::vector<std::mutex>>(CRYPTO_num_locks());
|
||||
CRYPTO_set_locking_callback(locking_callback);
|
||||
}
|
||||
|
||||
~SSLThreadLocks() {
|
||||
CRYPTO_set_locking_callback(nullptr);
|
||||
}
|
||||
~SSLThreadLocks() { CRYPTO_set_locking_callback(nullptr); }
|
||||
|
||||
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) {
|
||||
locks_[type].lock();
|
||||
locks[type].lock();
|
||||
} else {
|
||||
locks_[type].unlock();
|
||||
locks[type].unlock();
|
||||
}
|
||||
}
|
||||
|
||||
static std::vector<std::mutex> locks_;
|
||||
};
|
||||
|
||||
std::vector<std::mutex> SSLThreadLocks::locks_(CRYPTO_num_locks());
|
||||
#endif
|
||||
|
||||
class SSLInit {
|
||||
|
|
Loading…
Reference in a new issue