From 00cca4808186e53a9cafe7ddb75eac7d28afaf07 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Tue, 31 Aug 2021 23:20:36 +0800 Subject: [PATCH] src: register external references of TCPWrap for snapshot PR-URL: https://github.com/nodejs/node/pull/39961 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Michael Dawson --- src/node_external_reference.h | 1 + src/tcp_wrap.cc | 22 +++++++++++++++++++++- src/tcp_wrap.h | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/node_external_reference.h b/src/node_external_reference.h index 516a661b61c152..90035ae6966709 100644 --- a/src/node_external_reference.h +++ b/src/node_external_reference.h @@ -67,6 +67,7 @@ class ExternalReferenceRegistry { V(process_object) \ V(report) \ V(task_queue) \ + V(tcp_wrap) \ V(url) \ V(util) \ V(serdes) \ diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index cd7174984e2e36..84b18a1592d93c 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -21,12 +21,13 @@ #include "tcp_wrap.h" +#include "connect_wrap.h" #include "connection_wrap.h" #include "env-inl.h" #include "handle_wrap.h" #include "node_buffer.h" +#include "node_external_reference.h" #include "node_internals.h" -#include "connect_wrap.h" #include "stream_base-inl.h" #include "stream_wrap.h" #include "util-inl.h" @@ -120,6 +121,23 @@ void TCPWrap::Initialize(Local target, constants).Check(); } +void TCPWrap::RegisterExternalReferences(ExternalReferenceRegistry* registry) { + registry->Register(New); + registry->Register(Open); + registry->Register(Bind); + registry->Register(Listen); + registry->Register(Connect); + registry->Register(Bind6); + registry->Register(Connect6); + + registry->Register(GetSockOrPeerName); + registry->Register(GetSockOrPeerName); + registry->Register(SetNoDelay); + registry->Register(SetKeepAlive); +#ifdef _WIN32 + registry->Register(SetSimultaneousAccepts); +#endif +} void TCPWrap::New(const FunctionCallbackInfo& args) { // This constructor should not be exposed to public javascript. @@ -393,3 +411,5 @@ Local AddressToJS(Environment* env, } // namespace node NODE_MODULE_CONTEXT_AWARE_INTERNAL(tcp_wrap, node::TCPWrap::Initialize) +NODE_MODULE_EXTERNAL_REFERENCE(tcp_wrap, + node::TCPWrap::RegisterExternalReferences) diff --git a/src/tcp_wrap.h b/src/tcp_wrap.h index 0099eedb4bc629..3abf4ded19fd7c 100644 --- a/src/tcp_wrap.h +++ b/src/tcp_wrap.h @@ -29,6 +29,7 @@ namespace node { +class ExternalReferenceRegistry; class Environment; class TCPWrap : public ConnectionWrap { @@ -45,6 +46,7 @@ class TCPWrap : public ConnectionWrap { v8::Local unused, v8::Local context, void* priv); + static void RegisterExternalReferences(ExternalReferenceRegistry* registry); SET_NO_MEMORY_INFO() SET_SELF_SIZE(TCPWrap)