From 4d49aff3e503d629afcd245e353ca452cc15424a Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 27 Nov 2023 14:36:04 +0100 Subject: [PATCH] src: register udp_wrap external references PR-URL: https://github.com/nodejs/node/pull/50943 Refs: https://github.com/nodejs/node/issues/50924 Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell --- src/node_external_reference.h | 1 + src/udp_wrap.cc | 39 ++++++++++++++++++++++++++++++++++- src/udp_wrap.h | 3 +++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/node_external_reference.h b/src/node_external_reference.h index 09a24aeef1b07f..b1b6ca31766326 100644 --- a/src/node_external_reference.h +++ b/src/node_external_reference.h @@ -115,6 +115,7 @@ class ExternalReferenceRegistry { V(task_queue) \ V(tcp_wrap) \ V(tty_wrap) \ + V(udp_wrap) \ V(url) \ V(util) \ V(pipe_wrap) \ diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 4208a213260e26..d4249d7aac56e0 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -21,10 +21,11 @@ #include "udp_wrap.h" #include "env-inl.h" +#include "handle_wrap.h" #include "node_buffer.h" #include "node_errors.h" +#include "node_external_reference.h" #include "node_sockaddr-inl.h" -#include "handle_wrap.h" #include "req_wrap-inl.h" #include "util-inl.h" @@ -133,6 +134,12 @@ void UDPWrapBase::AddMethods(Environment* env, Local t) { SetProtoMethod(env->isolate(), t, "recvStop", RecvStop); } +void UDPWrapBase::RegisterExternalReferences( + ExternalReferenceRegistry* registry) { + registry->Register(RecvStart); + registry->Register(RecvStop); +} + UDPWrap::UDPWrap(Environment* env, Local object) : HandleWrap(env, object, @@ -229,6 +236,34 @@ void UDPWrap::Initialize(Local target, constants).Check(); } +void UDPWrap::RegisterExternalReferences(ExternalReferenceRegistry* registry) { + UDPWrapBase::RegisterExternalReferences(registry); + registry->Register(New); + registry->Register(GetFD); + + registry->Register(Open); + registry->Register(Bind); + registry->Register(Connect); + registry->Register(Send); + registry->Register(Bind6); + registry->Register(Connect6); + registry->Register(Send6); + registry->Register(Disconnect); + registry->Register(GetSockOrPeerName); + registry->Register(GetSockOrPeerName); + registry->Register(AddMembership); + registry->Register(DropMembership); + registry->Register(AddSourceSpecificMembership); + registry->Register(DropSourceSpecificMembership); + registry->Register(SetMulticastInterface); + registry->Register(SetLibuvInt32); + registry->Register(SetLibuvInt32); + registry->Register(SetLibuvInt32); + registry->Register(SetLibuvInt32); + registry->Register(BufferSize); + registry->Register(GetSendQueueSize); + registry->Register(GetSendQueueCount); +} void UDPWrap::New(const FunctionCallbackInfo& args) { CHECK(args.IsConstructCall()); @@ -807,3 +842,5 @@ void UDPWrap::GetSendQueueCount(const FunctionCallbackInfo& args) { } // namespace node NODE_BINDING_CONTEXT_AWARE_INTERNAL(udp_wrap, node::UDPWrap::Initialize) +NODE_BINDING_EXTERNAL_REFERENCE(udp_wrap, + node::UDPWrap::RegisterExternalReferences) diff --git a/src/udp_wrap.h b/src/udp_wrap.h index 3b8ca7df351a36..c0914dbf3a7f3f 100644 --- a/src/udp_wrap.h +++ b/src/udp_wrap.h @@ -32,6 +32,7 @@ namespace node { +class ExternalReferenceRegistry; class UDPWrapBase; // A listener that can be attached to an `UDPWrapBase` object and generally @@ -110,6 +111,7 @@ class UDPWrapBase { static void RecvStart(const v8::FunctionCallbackInfo& args); static void RecvStop(const v8::FunctionCallbackInfo& args); static void AddMethods(Environment* env, v8::Local t); + static void RegisterExternalReferences(ExternalReferenceRegistry* registry); private: UDPListener* listener_ = nullptr; @@ -126,6 +128,7 @@ class UDPWrap final : public HandleWrap, v8::Local unused, v8::Local context, void* priv); + static void RegisterExternalReferences(ExternalReferenceRegistry* registry); static void GetFD(const v8::FunctionCallbackInfo& args); static void New(const v8::FunctionCallbackInfo& args); static void Open(const v8::FunctionCallbackInfo& args);