mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 08:16:14 +02:00
Revert "Remove obsolete OpenSSL locking code"
This reverts commit aeb695c007
.
This commit is contained in:
parent
e302ba0e65
commit
4caeefaf00
2 changed files with 20 additions and 4 deletions
|
@ -15,6 +15,8 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include <openssl/crypto.h>
|
||||||
|
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
@ -78,6 +80,20 @@ string getArg(const string & opt,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* OpenSSL is not thread-safe by default - it will randomly crash
|
||||||
|
unless the user supplies a mutex locking function. So let's do
|
||||||
|
that. */
|
||||||
|
static std::vector<std::mutex> opensslLocks;
|
||||||
|
|
||||||
|
static void opensslLockCallback(int mode, int type, const char * file, int line)
|
||||||
|
{
|
||||||
|
if (mode & CRYPTO_LOCK)
|
||||||
|
opensslLocks[type].lock();
|
||||||
|
else
|
||||||
|
opensslLocks[type].unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void sigHandler(int signo) { }
|
static void sigHandler(int signo) { }
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,6 +105,10 @@ void initNix()
|
||||||
std::cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));
|
std::cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Initialise OpenSSL locking. */
|
||||||
|
opensslLocks = std::vector<std::mutex>(CRYPTO_num_locks());
|
||||||
|
CRYPTO_set_locking_callback(opensslLockCallback);
|
||||||
|
|
||||||
loadConfFile();
|
loadConfFile();
|
||||||
|
|
||||||
startSignalHandlerThread();
|
startSignalHandlerThread();
|
||||||
|
|
|
@ -13,10 +13,6 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#if OPENSSL_VERSION_NUMBER < 0x10101000L
|
|
||||||
#error "Unsupported version of OpenSSL, you need at least 1.1.1"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue