Skip to content

Commit

Permalink
Fix OpenSSL initialization.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 83eb7addf7d0407432fc8d4ba1a4cb6464818cc7
  • Loading branch information
levlam committed Jun 10, 2020
1 parent a726450 commit 8e7c6fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions benchmark/bench_crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ BENCH(SslRand, "ssl_rand_int32") {
std::vector<td::thread> v;
std::atomic<td::uint32> sum{0};
for (int i = 0; i < 3; i++) {
v.push_back(td::thread([&] {
v.emplace_back([&sum, n] {
td::int32 res = 0;
for (int j = 0; j < n; j++) {
res ^= td::Random::secure_int32();
}
sum += res;
}));
});
}
for (auto &x : v) {
x.join();
Expand Down Expand Up @@ -196,6 +196,8 @@ class Crc64Bench : public td::Benchmark {
};

int main() {
td::init_openssl_threads();

td::bench(Pbkdf2Bench());
td::bench(RandBench());
td::bench(CppRandBench());
Expand Down
3 changes: 3 additions & 0 deletions test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "td/utils/tests.h"

#include "td/utils/common.h"
#include "td/utils/crypto.h"
#include "td/utils/logging.h"

#include <cstring>
Expand All @@ -16,6 +17,8 @@
#endif

int main(int argc, char **argv) {
td::init_openssl_threads();

// TODO port OptionsParser to Windows
td::TestsRunner &runner = td::TestsRunner::get_default();
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(ERROR));
Expand Down

0 comments on commit 8e7c6fc

Please sign in to comment.