Skip to content

Commit

Permalink
src: register StreamBase while registering LibuvStreamWrap
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
RaisinTen committed Jun 5, 2022
1 parent 71071f8 commit 8576c2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/stream_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ void StreamBase::AddMethods(Environment* env, Local<FunctionTemplate> t) {

void StreamBase::RegisterExternalReferences(
ExternalReferenceRegistry* registry) {
static bool is_registered = false;
if (is_registered) return;
registry->Register(GetFD);
registry->Register(GetExternal);
registry->Register(GetBytesRead);
Expand All @@ -471,6 +473,7 @@ void StreamBase::RegisterExternalReferences(
registry->Register(
BaseObject::InternalFieldSet<StreamBase::kOnReadFunctionField,
&Value::IsFunction>);
is_registered = true;
}

void StreamBase::GetFD(const FunctionCallbackInfo<Value>& args) {
Expand Down
4 changes: 2 additions & 2 deletions src/stream_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "node_external_reference.h"
#include "pipe_wrap.h"
#include "req_wrap-inl.h"
#include "stream_base-inl.h"
#include "tcp_wrap.h"
#include "udp_wrap.h"
#include "util-inl.h"
Expand Down Expand Up @@ -108,8 +109,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,
Expand Down

0 comments on commit 8576c2f

Please sign in to comment.