diff --git a/fortuna.cpp b/fortuna.cpp index 01a41c4..498c239 100644 --- a/fortuna.cpp +++ b/fortuna.cpp @@ -42,7 +42,7 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void { std::string s; // synchronise reads and writes to the between // {generator,accumulator,fortuna} service threads - std::lock_guard lg(mtx); + std::unique_lock uq_lock(mtx); const int pools_to_use{ffsll(static_cast(get_reseed_ctr()))}; if (R.pools[0].get_s_length() >= min_pool_size && elapsed > R.Gen.reseed_interval) { @@ -71,6 +71,7 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void { n_bytes, n); n.clear(); } + uq_lock.unlock(); const auto end{std::chrono::system_clock::now()}; std::chrono::duration diff = end-start;