Skip to content

Commit

Permalink
src: register external references of TCPWrap for snapshot
Browse files Browse the repository at this point in the history
PR-URL: #39961
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <midawson@redhat.com>
  • Loading branch information
joyeecheung committed Sep 6, 2021
1 parent 3ec38f7 commit 995f945
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/node_external_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class ExternalReferenceRegistry {
V(process_object) \
V(report) \
V(task_queue) \
V(tcp_wrap) \
V(url) \
V(util) \
V(serdes) \
Expand Down
22 changes: 21 additions & 1 deletion src/tcp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -120,6 +121,23 @@ void TCPWrap::Initialize(Local<Object> 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<TCPWrap, uv_tcp_getsockname>);
registry->Register(GetSockOrPeerName<TCPWrap, uv_tcp_getpeername>);
registry->Register(SetNoDelay);
registry->Register(SetKeepAlive);
#ifdef _WIN32
registry->Register(SetSimultaneousAccepts);
#endif
}

void TCPWrap::New(const FunctionCallbackInfo<Value>& args) {
// This constructor should not be exposed to public javascript.
Expand Down Expand Up @@ -393,3 +411,5 @@ Local<Object> AddressToJS(Environment* env,
} // namespace node

NODE_MODULE_CONTEXT_AWARE_INTERNAL(tcp_wrap, node::TCPWrap::Initialize)
NODE_MODULE_EXTERNAL_REFERENCE(tcp_wrap,
node::TCPWrap::RegisterExternalReferences)
2 changes: 2 additions & 0 deletions src/tcp_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

namespace node {

class ExternalReferenceRegistry;
class Environment;

class TCPWrap : public ConnectionWrap<TCPWrap, uv_tcp_t> {
Expand All @@ -45,6 +46,7 @@ class TCPWrap : public ConnectionWrap<TCPWrap, uv_tcp_t> {
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv);
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);

SET_NO_MEMORY_INFO()
SET_SELF_SIZE(TCPWrap)
Expand Down

0 comments on commit 995f945

Please sign in to comment.