From 371adecc01e9394423c5f152ccb6d21e0e8d22dd Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Sun, 5 Jun 2022 18:01:01 +0530 Subject: [PATCH] src: register StreamBase while registering LibuvStreamWrap This resolves this TODO - https://github.com/nodejs/node/blob/71071f896aa9696b5d36bb3bec1c7217e7420509/src/stream_wrap.cc#L111-L112. Signed-off-by: Darshan Sen --- src/stream_base.cc | 3 +++ src/stream_wrap.cc | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stream_base.cc b/src/stream_base.cc index a9ea347ca6bd47..c641845d19c2b2 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -452,6 +452,8 @@ void StreamBase::AddMethods(Environment* env, Local t) { void StreamBase::RegisterExternalReferences( ExternalReferenceRegistry* registry) { + static bool is_registered = false; + if (is_registered) return; registry->Register(GetFD); registry->Register(GetExternal); registry->Register(GetBytesRead); @@ -471,6 +473,7 @@ void StreamBase::RegisterExternalReferences( registry->Register( BaseObject::InternalFieldSet); + is_registered = true; } void StreamBase::GetFD(const FunctionCallbackInfo& args) { diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index ff3df6bc5db7bd..ef85ba681f8588 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -108,8 +108,7 @@ void LibuvStreamWrap::RegisterExternalReferences( registry->Register(IsConstructCallCallback); registry->Register(GetWriteQueueSize); registry->Register(SetBlocking); - // TODO(joyee): StreamBase::RegisterExternalReferences() is called somewhere - // else but we may want to do it here too and guard it with a static flag. + StreamBase::RegisterExternalReferences(registry); } LibuvStreamWrap::LibuvStreamWrap(Environment* env,