src: avoid possible race during NodeBIO initialization · nodejs/node@28d4d5f · GitHub
Skip to content

Commit 28d4d5f

Browse files
addaleaxrvagg
authored andcommitted
src: avoid possible race during NodeBIO initialization
PR-URL: #21984 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 4590a1c commit 28d4d5f

4 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/node_crypto.cc

Lines changed: 2 additions & 0 deletions

src/node_crypto.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ extern int VerifyCallback(int preverify_ok, X509_STORE_CTX* ctx);
9797

9898
extern void UseExtraCaCerts(const std::string& file);
9999

100+
void InitCryptoOnce();
101+
100102
class SecureContext : public BaseObject {
101103
public:
102104
~SecureContext() override {

src/node_crypto_bio.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ const BIO_METHOD* NodeBIO::GetMethod() {
247247

248248
return &method;
249249
#else
250+
// This is called from InitCryptoOnce() to avoid race conditions during
251+
// initialization.
250252
static BIO_METHOD* method = nullptr;
251253

252254
if (method == nullptr) {

src/node_crypto_bio.h

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)