mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
src: avoid possible race during NodeBIO initialization
PR-URL: https://github.com/nodejs/node/pull/21984 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
987dc07111
commit
40ae307071
4 files changed
+8
No files matched your search
@@ -5141,6 +5141,8 @@ void InitCryptoOnce() {
|
||||
ERR_load_ENGINE_strings();
|
||||
ENGINE_load_builtin_engines();
|
||||
#endif // !OPENSSL_NO_ENGINE
|
||||
|
||||
NodeBIO::GetMethod();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -97,6 +97,8 @@ extern int VerifyCallback(int preverify_ok, X509_STORE_CTX* ctx);
|
||||
|
||||
extern void UseExtraCaCerts(const std::string& file);
|
||||
|
||||
void InitCryptoOnce();
|
||||
|
||||
class SecureContext : public BaseObject {
|
||||
public:
|
||||
~SecureContext() override {
|
||||
|
||||
@@ -247,6 +247,8 @@ const BIO_METHOD* NodeBIO::GetMethod() {
|
||||
|
||||
return &method;
|
||||
#else
|
||||
// This is called from InitCryptoOnce() to avoid race conditions during
|
||||
// initialization.
|
||||
static BIO_METHOD* method = nullptr;
|
||||
|
||||
if (method == nullptr) {
|
||||
|
||||
@@ -164,6 +164,8 @@ class NodeBIO : public MemoryRetainer {
|
||||
int eof_return_ = -1;
|
||||
Buffer* read_head_ = nullptr;
|
||||
Buffer* write_head_ = nullptr;
|
||||
|
||||
friend void node::crypto::InitCryptoOnce();
|
||||
};
|
||||
|
||||
} // namespace crypto
|
||||
|
||||
Reference in new issue
Block a user