diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/openssl/init/init.cpp | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/openssl/init/init.cpp')
-rw-r--r-- | library/cpp/openssl/init/init.cpp | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/library/cpp/openssl/init/init.cpp b/library/cpp/openssl/init/init.cpp index ae68ef08ea..a565c0ae5b 100644 --- a/library/cpp/openssl/init/init.cpp +++ b/library/cpp/openssl/init/init.cpp @@ -1,66 +1,66 @@ -#include "init.h" - -#include <util/generic/singleton.h> -#include <util/generic/vector.h> -#include <util/generic/ptr.h> -#include <util/generic/buffer.h> - -#include <util/system/yassert.h> -#include <util/system/mutex.h> -#include <util/system/thread.h> - -#include <util/random/entropy.h> -#include <util/stream/input.h> - -#include <openssl/bio.h> -#include <openssl/ssl.h> -#include <openssl/err.h> -#include <openssl/rand.h> -#include <openssl/conf.h> -#include <openssl/crypto.h> - -namespace { - struct TInitSsl { - struct TOpensslLocks { - inline TOpensslLocks() - : Mutexes(CRYPTO_num_locks()) - { - for (auto& mpref : Mutexes) { - mpref.Reset(new TMutex()); - } - } - - inline void LockOP(int mode, int n) { - auto& mutex = *Mutexes.at(n); - - if (mode & CRYPTO_LOCK) { - mutex.Acquire(); - } else { - mutex.Release(); - } - } - +#include "init.h" + +#include <util/generic/singleton.h> +#include <util/generic/vector.h> +#include <util/generic/ptr.h> +#include <util/generic/buffer.h> + +#include <util/system/yassert.h> +#include <util/system/mutex.h> +#include <util/system/thread.h> + +#include <util/random/entropy.h> +#include <util/stream/input.h> + +#include <openssl/bio.h> +#include <openssl/ssl.h> +#include <openssl/err.h> +#include <openssl/rand.h> +#include <openssl/conf.h> +#include <openssl/crypto.h> + +namespace { + struct TInitSsl { + struct TOpensslLocks { + inline TOpensslLocks() + : Mutexes(CRYPTO_num_locks()) + { + for (auto& mpref : Mutexes) { + mpref.Reset(new TMutex()); + } + } + + inline void LockOP(int mode, int n) { + auto& mutex = *Mutexes.at(n); + + if (mode & CRYPTO_LOCK) { + mutex.Acquire(); + } else { + mutex.Release(); + } + } + TVector<TAutoPtr<TMutex>> Mutexes; - }; - - inline TInitSsl() { + }; + + inline TInitSsl() { OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, nullptr); - } - - inline ~TInitSsl() { + } + + inline ~TInitSsl() { OPENSSL_cleanup(); - } - - static void LockingFunction(int mode, int n, const char* /*file*/, int /*line*/) { - Singleton<TOpensslLocks>()->LockOP(mode, n); - } - - static unsigned long ThreadIdFunction() { - return TThread::CurrentThreadId(); - } - }; -} - -void InitOpenSSL() { + } + + static void LockingFunction(int mode, int n, const char* /*file*/, int /*line*/) { + Singleton<TOpensslLocks>()->LockOP(mode, n); + } + + static unsigned long ThreadIdFunction() { + return TThread::CurrentThreadId(); + } + }; +} + +void InitOpenSSL() { (void)SingletonWithPriority<TInitSsl, 0>(); -} +} |