diff options
author | Russell Yanofsky <russ@yanofsky.org> | 2017-11-08 17:07:40 -0500 |
---|---|---|
committer | Russell Yanofsky <russ@yanofsky.org> | 2018-08-03 07:11:37 -0500 |
commit | 9c4dc597ddc66acfd58a945a5ab11f833731abba (patch) | |
tree | 65dd64eda8515ccc9245a1b4bb2211d60c620c07 /src/random.cpp | |
parent | 1382913e61f5db6ba849b1e261e8aefcd5a1ae68 (diff) |
Use LOCK macros for non-recursive locks
Instead of std::unique_lock.
Diffstat (limited to 'src/random.cpp')
-rw-r--r-- | src/random.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/random.cpp b/src/random.cpp index fee6c2d92a..7f05bcf9a2 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -12,6 +12,7 @@ #include <wincrypt.h> #endif #include <logging.h> // for LogPrint() +#include <sync.h> // for WAIT_LOCK #include <utiltime.h> // for GetTime() #include <stdlib.h> @@ -295,7 +296,7 @@ void RandAddSeedSleep() } -static std::mutex cs_rng_state; +static CWaitableCriticalSection cs_rng_state; static unsigned char rng_state[32] = {0}; static uint64_t rng_counter = 0; @@ -305,7 +306,7 @@ static void AddDataToRng(void* data, size_t len) { hasher.Write((const unsigned char*)data, len); unsigned char buf[64]; { - std::unique_lock<std::mutex> lock(cs_rng_state); + WAIT_LOCK(cs_rng_state, lock); hasher.Write(rng_state, sizeof(rng_state)); hasher.Write((const unsigned char*)&rng_counter, sizeof(rng_counter)); ++rng_counter; @@ -337,7 +338,7 @@ void GetStrongRandBytes(unsigned char* out, int num) // Combine with and update state { - std::unique_lock<std::mutex> lock(cs_rng_state); + WAIT_LOCK(cs_rng_state, lock); hasher.Write(rng_state, sizeof(rng_state)); hasher.Write((const unsigned char*)&rng_counter, sizeof(rng_counter)); ++rng_counter; |