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 <raisinten@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/43321
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Darshan Sen authored and Michaël Zasso committed 2022-07-31 09:44:51 +02:00
1 parent 6fcb349fda
commit bf553fd26a
2 files changed
+6 -2

No files matched your search

+5
View File
@@ -452,6 +452,10 @@ void StreamBase::AddMethods(Environment* env, Local<FunctionTemplate> t) {
void StreamBase::RegisterExternalReferences(
ExternalReferenceRegistry* registry) {
// This function is called by a single thread during start up, so it is safe
// to use a local static variable here.
static bool is_registered = false;
if (is_registered) return;
registry->Register(GetFD);
registry->Register(GetExternal);
registry->Register(GetBytesRead);
@@ -471,6 +475,7 @@ void StreamBase::RegisterExternalReferences(
registry->Register(
BaseObject::InternalFieldSet<StreamBase::kOnReadFunctionField,
&Value::IsFunction>);
is_registered = true;
}
void StreamBase::GetFD(const FunctionCallbackInfo<Value>& args) {
+1 -2
View File
@@ -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,