Skip to content

Commit 00cca48

Browse files
joyeecheungBethGriggs
authored andcommittedSep 21, 2021
src: register external references of TCPWrap for snapshot
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>
1 parent 6095fb0 commit 00cca48

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed
 

‎src/node_external_reference.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class ExternalReferenceRegistry {
6767
V(process_object) \
6868
V(report) \
6969
V(task_queue) \
70+
V(tcp_wrap) \
7071
V(url) \
7172
V(util) \
7273
V(serdes) \

‎src/tcp_wrap.cc

+21-1
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121

2222
#include "tcp_wrap.h"
2323

24+
#include "connect_wrap.h"
2425
#include "connection_wrap.h"
2526
#include "env-inl.h"
2627
#include "handle_wrap.h"
2728
#include "node_buffer.h"
29+
#include "node_external_reference.h"
2830
#include "node_internals.h"
29-
#include "connect_wrap.h"
3031
#include "stream_base-inl.h"
3132
#include "stream_wrap.h"
3233
#include "util-inl.h"
@@ -120,6 +121,23 @@ void TCPWrap::Initialize(Local<Object> target,
120121
constants).Check();
121122
}
122123

124+
void TCPWrap::RegisterExternalReferences(ExternalReferenceRegistry* registry) {
125+
registry->Register(New);
126+
registry->Register(Open);
127+
registry->Register(Bind);
128+
registry->Register(Listen);
129+
registry->Register(Connect);
130+
registry->Register(Bind6);
131+
registry->Register(Connect6);
132+
133+
registry->Register(GetSockOrPeerName<TCPWrap, uv_tcp_getsockname>);
134+
registry->Register(GetSockOrPeerName<TCPWrap, uv_tcp_getpeername>);
135+
registry->Register(SetNoDelay);
136+
registry->Register(SetKeepAlive);
137+
#ifdef _WIN32
138+
registry->Register(SetSimultaneousAccepts);
139+
#endif
140+
}
123141

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

395413
NODE_MODULE_CONTEXT_AWARE_INTERNAL(tcp_wrap, node::TCPWrap::Initialize)
414+
NODE_MODULE_EXTERNAL_REFERENCE(tcp_wrap,
415+
node::TCPWrap::RegisterExternalReferences)

‎src/tcp_wrap.h

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
namespace node {
3131

32+
class ExternalReferenceRegistry;
3233
class Environment;
3334

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

4951
SET_NO_MEMORY_INFO()
5052
SET_SELF_SIZE(TCPWrap)

0 commit comments

Comments
 (0)
Please sign in to comment.