mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 19:06:49 +01:00
Replace ACE thread/mutex in OpenSSLCrypto
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "Timer.h"
|
||||
#include <ace/Singleton.h>
|
||||
#include <ace/Atomic_Op.h>
|
||||
#include <ace/Null_Mutex.h>
|
||||
#include "SharedDefines.h"
|
||||
#include "QueryResult.h"
|
||||
#include "Callback.h"
|
||||
|
||||
@@ -17,28 +17,23 @@
|
||||
|
||||
#include <OpenSSLCrypto.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <ace/Thread_Mutex.h>
|
||||
#include <vector>
|
||||
#include <ace/Thread.h>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
||||
std::vector<ACE_Thread_Mutex*> cryptoLocks;
|
||||
std::vector<std::mutex*> cryptoLocks;
|
||||
|
||||
static void lockingCallback(int mode, int type, const char* /*file*/, int /*line*/)
|
||||
{
|
||||
if (mode & CRYPTO_LOCK)
|
||||
cryptoLocks[type]->acquire();
|
||||
cryptoLocks[type]->lock();
|
||||
else
|
||||
cryptoLocks[type]->release();
|
||||
cryptoLocks[type]->unlock();
|
||||
}
|
||||
|
||||
static void threadIdCallback(CRYPTO_THREADID * id)
|
||||
{
|
||||
/// ACE_thread_t turns out to be a struct under Mac OS.
|
||||
#ifndef __APPLE__
|
||||
CRYPTO_THREADID_set_numeric(id, ACE_Thread::self());
|
||||
#else
|
||||
CRYPTO_THREADID_set_pointer(id, ACE_Thread::self());
|
||||
#endif
|
||||
CRYPTO_THREADID_set_numeric(id, std::this_thread::get_id().hash());
|
||||
}
|
||||
|
||||
void OpenSSLCrypto::threadsSetup()
|
||||
@@ -46,7 +41,7 @@ void OpenSSLCrypto::threadsSetup()
|
||||
cryptoLocks.resize(CRYPTO_num_locks());
|
||||
for(int i = 0 ; i < CRYPTO_num_locks(); ++i)
|
||||
{
|
||||
cryptoLocks[i] = new ACE_Thread_Mutex();
|
||||
cryptoLocks[i] = new std::mutex;
|
||||
}
|
||||
CRYPTO_THREADID_set_callback(threadIdCallback);
|
||||
CRYPTO_set_locking_callback(lockingCallback);
|
||||
@@ -61,4 +56,4 @@ void OpenSSLCrypto::threadsCleanup()
|
||||
delete cryptoLocks[i];
|
||||
}
|
||||
cryptoLocks.resize(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user