@encharm/cws 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -7
- package/dist/bindings/cws_darwin_arm64_node108.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node83.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node93.node +0 -0
- package/dist/bindings/cws_darwin_x64_node108.node +0 -0
- package/dist/bindings/cws_darwin_x64_node115.node +0 -0
- package/dist/bindings/cws_darwin_x64_node83.node +0 -0
- package/dist/bindings/cws_darwin_x64_node93.node +0 -0
- package/dist/bindings/cws_linux_arm64_node108.node +0 -0
- package/dist/bindings/cws_linux_arm64_node115.node +0 -0
- package/dist/bindings/cws_linux_arm64_node83.node +0 -0
- package/dist/bindings/cws_linux_arm64_node93.node +0 -0
- package/dist/bindings/cws_linux_x64_node108.node +0 -0
- package/dist/bindings/cws_linux_x64_node115.node +0 -0
- package/dist/bindings/cws_linux_x64_node83.node +0 -0
- package/dist/bindings/cws_linux_x64_node93.node +0 -0
- package/dist/bindings/cws_win32_x64_node108.node +0 -0
- package/dist/bindings/cws_win32_x64_node115.node +0 -0
- package/dist/bindings/cws_win32_x64_node83.node +0 -0
- package/dist/bindings/cws_win32_x64_node93.node +0 -0
- package/dist/shared.js +1 -1
- package/package.json +5 -5
- package/src/Addon.cpp +4 -12
- package/src/Addon.h +55 -90
- package/src/Socket.h +1 -0
- package/src/cSNode.cpp +3 -8
- package/src/headers/20/acorn_version.h +6 -0
- package/src/headers/20/aliased_buffer-inl.h +243 -0
- package/src/headers/20/aliased_buffer.h +206 -0
- package/src/headers/20/aliased_struct-inl.h +54 -0
- package/src/headers/20/aliased_struct.h +63 -0
- package/src/headers/20/async_wrap-inl.h +93 -0
- package/src/headers/20/async_wrap.h +252 -0
- package/src/headers/20/base64-inl.h +193 -0
- package/src/headers/20/base64.h +53 -0
- package/src/headers/20/base64_version.h +6 -0
- package/src/headers/20/base_object-inl.h +316 -0
- package/src/headers/20/base_object.h +320 -0
- package/src/headers/20/base_object_types.h +73 -0
- package/src/headers/20/blob_serializer_deserializer-inl.h +361 -0
- package/src/headers/20/blob_serializer_deserializer.h +132 -0
- package/src/headers/20/callback_queue-inl.h +97 -0
- package/src/headers/20/callback_queue.h +79 -0
- package/src/headers/20/cares_wrap.h +524 -0
- package/src/headers/20/cjs_module_lexer_version.h +6 -0
- package/src/headers/20/cleanup_queue-inl.h +62 -0
- package/src/headers/20/cleanup_queue.h +85 -0
- package/src/headers/20/connect_wrap.h +26 -0
- package/src/headers/20/connection_wrap.h +29 -0
- package/src/headers/20/cppgc/DEPS +8 -0
- package/src/headers/20/cppgc/OWNERS +2 -0
- package/src/headers/20/cppgc/README.md +135 -0
- package/src/headers/20/cppgc/allocation.h +310 -0
- package/src/headers/20/cppgc/common.h +28 -0
- package/src/headers/20/cppgc/cross-thread-persistent.h +466 -0
- package/src/headers/20/cppgc/custom-space.h +97 -0
- package/src/headers/20/cppgc/default-platform.h +67 -0
- package/src/headers/20/cppgc/ephemeron-pair.h +30 -0
- package/src/headers/20/cppgc/explicit-management.h +100 -0
- package/src/headers/20/cppgc/garbage-collected.h +106 -0
- package/src/headers/20/cppgc/heap-consistency.h +309 -0
- package/src/headers/20/cppgc/heap-handle.h +48 -0
- package/src/headers/20/cppgc/heap-state.h +82 -0
- package/src/headers/20/cppgc/heap-statistics.h +120 -0
- package/src/headers/20/cppgc/heap.h +202 -0
- package/src/headers/20/cppgc/internal/api-constants.h +68 -0
- package/src/headers/20/cppgc/internal/atomic-entry-flag.h +48 -0
- package/src/headers/20/cppgc/internal/base-page-handle.h +45 -0
- package/src/headers/20/cppgc/internal/caged-heap-local-data.h +111 -0
- package/src/headers/20/cppgc/internal/caged-heap.h +61 -0
- package/src/headers/20/cppgc/internal/compiler-specific.h +38 -0
- package/src/headers/20/cppgc/internal/finalizer-trait.h +93 -0
- package/src/headers/20/cppgc/internal/gc-info.h +157 -0
- package/src/headers/20/cppgc/internal/logging.h +50 -0
- package/src/headers/20/cppgc/internal/member-storage.h +248 -0
- package/src/headers/20/cppgc/internal/name-trait.h +137 -0
- package/src/headers/20/cppgc/internal/persistent-node.h +214 -0
- package/src/headers/20/cppgc/internal/pointer-policies.h +243 -0
- package/src/headers/20/cppgc/internal/write-barrier.h +487 -0
- package/src/headers/20/cppgc/liveness-broker.h +78 -0
- package/src/headers/20/cppgc/macros.h +35 -0
- package/src/headers/20/cppgc/member.h +604 -0
- package/src/headers/20/cppgc/name-provider.h +65 -0
- package/src/headers/20/cppgc/object-size-trait.h +58 -0
- package/src/headers/20/cppgc/persistent.h +373 -0
- package/src/headers/20/cppgc/platform.h +158 -0
- package/src/headers/20/cppgc/prefinalizer.h +75 -0
- package/src/headers/20/cppgc/process-heap-statistics.h +36 -0
- package/src/headers/20/cppgc/sentinel-pointer.h +32 -0
- package/src/headers/20/cppgc/source-location.h +92 -0
- package/src/headers/20/cppgc/testing.h +106 -0
- package/src/headers/20/cppgc/trace-trait.h +120 -0
- package/src/headers/20/cppgc/type-traits.h +250 -0
- package/src/headers/20/cppgc/visitor.h +426 -0
- package/src/headers/20/crypto/crypto_clienthello.h +131 -0
- package/src/headers/20/crypto/crypto_context.h +160 -0
- package/src/headers/20/crypto/crypto_keys.h +416 -0
- package/src/headers/20/crypto/crypto_tls.h +295 -0
- package/src/headers/20/crypto/crypto_util.h +805 -0
- package/src/headers/20/crypto_clienthello.h +131 -0
- package/src/headers/20/debug_utils-inl.h +226 -0
- package/src/headers/20/debug_utils.h +188 -0
- package/src/headers/20/diagnosticfilename-inl.h +33 -0
- package/src/headers/20/encoding_binding.h +59 -0
- package/src/headers/20/env-inl.h +923 -0
- package/src/headers/20/env.h +1193 -0
- package/src/headers/20/env_properties.h +444 -0
- package/src/headers/20/handle_wrap.h +123 -0
- package/src/headers/20/histogram-inl.h +107 -0
- package/src/headers/20/histogram.h +240 -0
- package/src/headers/20/inspector_agent.h +144 -0
- package/src/headers/20/inspector_io.h +78 -0
- package/src/headers/20/inspector_profiler.h +149 -0
- package/src/headers/20/inspector_socket.h +60 -0
- package/src/headers/20/inspector_socket_server.h +110 -0
- package/src/headers/20/js_native_api.h +591 -0
- package/src/headers/20/js_native_api_types.h +168 -0
- package/src/headers/20/js_native_api_v8.h +426 -0
- package/src/headers/20/js_native_api_v8_internals.h +39 -0
- package/src/headers/20/js_stream.h +52 -0
- package/src/headers/20/json_parser.h +38 -0
- package/src/headers/20/json_utils.h +172 -0
- package/src/headers/20/memory_tracker-inl.h +356 -0
- package/src/headers/20/memory_tracker.h +289 -0
- package/src/headers/20/module_wrap.h +117 -0
- package/src/headers/20/node.h +1514 -0
- package/src/headers/20/node_api.h +260 -0
- package/src/headers/20/node_api_internals.h +42 -0
- package/src/headers/20/node_api_types.h +52 -0
- package/src/headers/20/node_binding.h +142 -0
- package/src/headers/20/node_blob.h +159 -0
- package/src/headers/20/node_bob-inl.h +36 -0
- package/src/headers/20/node_bob.h +107 -0
- package/src/headers/20/node_buffer.h +92 -0
- package/src/headers/20/node_builtins.h +197 -0
- package/src/headers/20/node_constants.h +79 -0
- package/src/headers/20/node_context_data.h +98 -0
- package/src/headers/20/node_contextify.h +182 -0
- package/src/headers/20/node_crypto.h +56 -0
- package/src/headers/20/node_dir.h +52 -0
- package/src/headers/20/node_dotenv.h +37 -0
- package/src/headers/20/node_errors.h +313 -0
- package/src/headers/20/node_exit_code.h +54 -0
- package/src/headers/20/node_external_reference.h +172 -0
- package/src/headers/20/node_file-inl.h +357 -0
- package/src/headers/20/node_file.h +524 -0
- package/src/headers/20/node_http2.h +1146 -0
- package/src/headers/20/node_http2_state.h +147 -0
- package/src/headers/20/node_http_common-inl.h +201 -0
- package/src/headers/20/node_http_common.h +532 -0
- package/src/headers/20/node_i18n.h +145 -0
- package/src/headers/20/node_internals.h +443 -0
- package/src/headers/20/node_main_instance.h +67 -0
- package/src/headers/20/node_mem-inl.h +112 -0
- package/src/headers/20/node_mem.h +45 -0
- package/src/headers/20/node_messaging.h +377 -0
- package/src/headers/20/node_metadata.h +138 -0
- package/src/headers/20/node_mutex.h +323 -0
- package/src/headers/20/node_object_wrap.h +132 -0
- package/src/headers/20/node_options-inl.h +478 -0
- package/src/headers/20/node_options.h +538 -0
- package/src/headers/20/node_perf.h +166 -0
- package/src/headers/20/node_perf_common.h +98 -0
- package/src/headers/20/node_platform.h +195 -0
- package/src/headers/20/node_process-inl.h +26 -0
- package/src/headers/20/node_process.h +99 -0
- package/src/headers/20/node_realm-inl.h +139 -0
- package/src/headers/20/node_realm.h +184 -0
- package/src/headers/20/node_report.h +42 -0
- package/src/headers/20/node_revert.h +82 -0
- package/src/headers/20/node_root_certs.h +3443 -0
- package/src/headers/20/node_sea.h +56 -0
- package/src/headers/20/node_shadow_realm.h +46 -0
- package/src/headers/20/node_snapshot_builder.h +54 -0
- package/src/headers/20/node_snapshotable.h +164 -0
- package/src/headers/20/node_sockaddr-inl.h +266 -0
- package/src/headers/20/node_sockaddr.h +405 -0
- package/src/headers/20/node_stat_watcher.h +73 -0
- package/src/headers/20/node_threadsafe_cow-inl.h +54 -0
- package/src/headers/20/node_threadsafe_cow.h +105 -0
- package/src/headers/20/node_union_bytes.h +81 -0
- package/src/headers/20/node_url.h +92 -0
- package/src/headers/20/node_v8.h +77 -0
- package/src/headers/20/node_v8_platform-inl.h +205 -0
- package/src/headers/20/node_version.h +109 -0
- package/src/headers/20/node_wasi.h +184 -0
- package/src/headers/20/node_wasm_web_api.h +55 -0
- package/src/headers/20/node_watchdog.h +154 -0
- package/src/headers/20/node_worker.h +151 -0
- package/src/headers/20/permission/child_process_permission.h +28 -0
- package/src/headers/20/permission/fs_permission.h +152 -0
- package/src/headers/20/permission/permission.h +71 -0
- package/src/headers/20/permission/permission_base.h +49 -0
- package/src/headers/20/permission/worker_permission.h +28 -0
- package/src/headers/20/pipe_wrap.h +80 -0
- package/src/headers/20/req_wrap-inl.h +171 -0
- package/src/headers/20/req_wrap.h +77 -0
- package/src/headers/20/spawn_sync.h +242 -0
- package/src/headers/20/stream_base-inl.h +173 -0
- package/src/headers/20/stream_base.h +469 -0
- package/src/headers/20/stream_pipe.h +76 -0
- package/src/headers/20/stream_wrap.h +131 -0
- package/src/headers/20/string_bytes.h +120 -0
- package/src/headers/20/string_decoder-inl.h +37 -0
- package/src/headers/20/string_decoder.h +50 -0
- package/src/headers/20/string_search.h +638 -0
- package/src/headers/20/tcp_wrap.h +105 -0
- package/src/headers/20/threadpoolwork-inl.h +70 -0
- package/src/headers/20/timer_wrap-inl.h +32 -0
- package/src/headers/20/timer_wrap.h +85 -0
- package/src/headers/20/timers.h +70 -0
- package/src/headers/20/tracing/agent.h +195 -0
- package/src/headers/20/tracing/trace_event.h +720 -0
- package/src/headers/20/tracing/trace_event_common.h +1109 -0
- package/src/headers/20/tty_wrap.h +65 -0
- package/src/headers/20/udp_wrap.h +227 -0
- package/src/headers/20/undici_version.h +6 -0
- package/src/headers/20/util-inl.h +623 -0
- package/src/headers/20/util.h +988 -0
- package/src/headers/20/v8-cppgc.h +245 -0
- package/src/headers/20/v8-fast-api-calls.h +957 -0
- package/dist/bindings/cws_darwin_arm64_node64.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node72.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node79.node +0 -0
- package/dist/bindings/cws_darwin_x64_node64.node +0 -0
- package/dist/bindings/cws_darwin_x64_node72.node +0 -0
- package/dist/bindings/cws_darwin_x64_node79.node +0 -0
- package/dist/bindings/cws_linux_x64_node64.node +0 -0
- package/dist/bindings/cws_linux_x64_node72.node +0 -0
- package/dist/bindings/cws_linux_x64_node79.node +0 -0
- package/dist/bindings/cws_win32_x64_node64.node +0 -0
- package/dist/bindings/cws_win32_x64_node72.node +0 -0
- package/dist/bindings/cws_win32_x64_node79.node +0 -0
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
#ifndef SRC_CARES_WRAP_H_
|
|
2
|
+
#define SRC_CARES_WRAP_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#define CARES_STATICLIB
|
|
7
|
+
|
|
8
|
+
#include "async_wrap.h"
|
|
9
|
+
#include "base_object.h"
|
|
10
|
+
#include "env.h"
|
|
11
|
+
#include "memory_tracker.h"
|
|
12
|
+
#include "node.h"
|
|
13
|
+
#include "node_internals.h"
|
|
14
|
+
#include "util.h"
|
|
15
|
+
|
|
16
|
+
#include "ares.h"
|
|
17
|
+
#include "v8.h"
|
|
18
|
+
#include "uv.h"
|
|
19
|
+
|
|
20
|
+
#include <unordered_set>
|
|
21
|
+
|
|
22
|
+
#ifdef __POSIX__
|
|
23
|
+
# include <netdb.h>
|
|
24
|
+
#endif // __POSIX__
|
|
25
|
+
|
|
26
|
+
# include <ares_nameser.h>
|
|
27
|
+
|
|
28
|
+
namespace node {
|
|
29
|
+
namespace cares_wrap {
|
|
30
|
+
|
|
31
|
+
constexpr int ns_t_cname_or_a = -1;
|
|
32
|
+
constexpr int DNS_ESETSRVPENDING = -1000;
|
|
33
|
+
|
|
34
|
+
class ChannelWrap;
|
|
35
|
+
|
|
36
|
+
inline void safe_free_hostent(struct hostent* host);
|
|
37
|
+
|
|
38
|
+
using HostEntPointer = DeleteFnPtr<hostent, ares_free_hostent>;
|
|
39
|
+
using SafeHostEntPointer = DeleteFnPtr<hostent, safe_free_hostent>;
|
|
40
|
+
|
|
41
|
+
inline const char* ToErrorCodeString(int status) {
|
|
42
|
+
switch (status) {
|
|
43
|
+
#define V(code) case ARES_##code: return #code;
|
|
44
|
+
V(EADDRGETNETWORKPARAMS)
|
|
45
|
+
V(EBADFAMILY)
|
|
46
|
+
V(EBADFLAGS)
|
|
47
|
+
V(EBADHINTS)
|
|
48
|
+
V(EBADNAME)
|
|
49
|
+
V(EBADQUERY)
|
|
50
|
+
V(EBADRESP)
|
|
51
|
+
V(EBADSTR)
|
|
52
|
+
V(ECANCELLED)
|
|
53
|
+
V(ECONNREFUSED)
|
|
54
|
+
V(EDESTRUCTION)
|
|
55
|
+
V(EFILE)
|
|
56
|
+
V(EFORMERR)
|
|
57
|
+
V(ELOADIPHLPAPI)
|
|
58
|
+
V(ENODATA)
|
|
59
|
+
V(ENOMEM)
|
|
60
|
+
V(ENONAME)
|
|
61
|
+
V(ENOTFOUND)
|
|
62
|
+
V(ENOTIMP)
|
|
63
|
+
V(ENOTINITIALIZED)
|
|
64
|
+
V(EOF)
|
|
65
|
+
V(EREFUSED)
|
|
66
|
+
V(ESERVFAIL)
|
|
67
|
+
V(ETIMEOUT)
|
|
68
|
+
#undef V
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return "UNKNOWN_ARES_ERROR";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
inline void cares_wrap_hostent_cpy(
|
|
75
|
+
struct hostent* dest,
|
|
76
|
+
const struct hostent* src) {
|
|
77
|
+
dest->h_addr_list = nullptr;
|
|
78
|
+
dest->h_addrtype = 0;
|
|
79
|
+
dest->h_aliases = nullptr;
|
|
80
|
+
dest->h_length = 0;
|
|
81
|
+
dest->h_name = nullptr;
|
|
82
|
+
|
|
83
|
+
/* copy `h_name` */
|
|
84
|
+
size_t name_size = strlen(src->h_name) + 1;
|
|
85
|
+
dest->h_name = node::Malloc<char>(name_size);
|
|
86
|
+
memcpy(dest->h_name, src->h_name, name_size);
|
|
87
|
+
|
|
88
|
+
/* copy `h_aliases` */
|
|
89
|
+
size_t alias_count;
|
|
90
|
+
for (alias_count = 0;
|
|
91
|
+
src->h_aliases[alias_count] != nullptr;
|
|
92
|
+
alias_count++) {
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
dest->h_aliases = node::Malloc<char*>(alias_count + 1);
|
|
96
|
+
for (size_t i = 0; i < alias_count; i++) {
|
|
97
|
+
const size_t cur_alias_size = strlen(src->h_aliases[i]) + 1;
|
|
98
|
+
dest->h_aliases[i] = node::Malloc(cur_alias_size);
|
|
99
|
+
memcpy(dest->h_aliases[i], src->h_aliases[i], cur_alias_size);
|
|
100
|
+
}
|
|
101
|
+
dest->h_aliases[alias_count] = nullptr;
|
|
102
|
+
|
|
103
|
+
/* copy `h_addr_list` */
|
|
104
|
+
size_t list_count;
|
|
105
|
+
for (list_count = 0;
|
|
106
|
+
src->h_addr_list[list_count] != nullptr;
|
|
107
|
+
list_count++) {
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
dest->h_addr_list = node::Malloc<char*>(list_count + 1);
|
|
111
|
+
for (size_t i = 0; i < list_count; i++) {
|
|
112
|
+
dest->h_addr_list[i] = node::Malloc(src->h_length);
|
|
113
|
+
memcpy(dest->h_addr_list[i], src->h_addr_list[i], src->h_length);
|
|
114
|
+
}
|
|
115
|
+
dest->h_addr_list[list_count] = nullptr;
|
|
116
|
+
|
|
117
|
+
/* work after work */
|
|
118
|
+
dest->h_length = src->h_length;
|
|
119
|
+
dest->h_addrtype = src->h_addrtype;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
struct NodeAresTask final : public MemoryRetainer {
|
|
124
|
+
ChannelWrap* channel;
|
|
125
|
+
ares_socket_t sock;
|
|
126
|
+
uv_poll_t poll_watcher;
|
|
127
|
+
|
|
128
|
+
inline void MemoryInfo(MemoryTracker* trakcer) const override;
|
|
129
|
+
SET_MEMORY_INFO_NAME(NodeAresTask)
|
|
130
|
+
SET_SELF_SIZE(NodeAresTask)
|
|
131
|
+
|
|
132
|
+
struct Hash {
|
|
133
|
+
inline size_t operator()(NodeAresTask* a) const {
|
|
134
|
+
return std::hash<ares_socket_t>()(a->sock);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
struct Equal {
|
|
139
|
+
inline bool operator()(NodeAresTask* a, NodeAresTask* b) const {
|
|
140
|
+
return a->sock == b->sock;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
static NodeAresTask* Create(ChannelWrap* channel, ares_socket_t sock);
|
|
145
|
+
|
|
146
|
+
using List = std::unordered_set<NodeAresTask*, Hash, Equal>;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
class ChannelWrap final : public AsyncWrap {
|
|
150
|
+
public:
|
|
151
|
+
ChannelWrap(
|
|
152
|
+
Environment* env,
|
|
153
|
+
v8::Local<v8::Object> object,
|
|
154
|
+
int timeout,
|
|
155
|
+
int tries);
|
|
156
|
+
~ChannelWrap() override;
|
|
157
|
+
|
|
158
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
159
|
+
|
|
160
|
+
void Setup();
|
|
161
|
+
void EnsureServers();
|
|
162
|
+
void StartTimer();
|
|
163
|
+
void CloseTimer();
|
|
164
|
+
|
|
165
|
+
void ModifyActivityQueryCount(int count);
|
|
166
|
+
|
|
167
|
+
inline uv_timer_t* timer_handle() { return timer_handle_; }
|
|
168
|
+
inline ares_channel cares_channel() { return channel_; }
|
|
169
|
+
inline void set_query_last_ok(bool ok) { query_last_ok_ = ok; }
|
|
170
|
+
inline void set_is_servers_default(bool is_default) {
|
|
171
|
+
is_servers_default_ = is_default;
|
|
172
|
+
}
|
|
173
|
+
inline int active_query_count() { return active_query_count_; }
|
|
174
|
+
inline NodeAresTask::List* task_list() { return &task_list_; }
|
|
175
|
+
|
|
176
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
177
|
+
SET_MEMORY_INFO_NAME(ChannelWrap)
|
|
178
|
+
SET_SELF_SIZE(ChannelWrap)
|
|
179
|
+
|
|
180
|
+
static void AresTimeout(uv_timer_t* handle);
|
|
181
|
+
|
|
182
|
+
private:
|
|
183
|
+
uv_timer_t* timer_handle_ = nullptr;
|
|
184
|
+
ares_channel channel_ = nullptr;
|
|
185
|
+
bool query_last_ok_ = true;
|
|
186
|
+
bool is_servers_default_ = true;
|
|
187
|
+
bool library_inited_ = false;
|
|
188
|
+
int timeout_;
|
|
189
|
+
int tries_;
|
|
190
|
+
int active_query_count_ = 0;
|
|
191
|
+
NodeAresTask::List task_list_;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
class GetAddrInfoReqWrap final : public ReqWrap<uv_getaddrinfo_t> {
|
|
195
|
+
public:
|
|
196
|
+
GetAddrInfoReqWrap(Environment* env,
|
|
197
|
+
v8::Local<v8::Object> req_wrap_obj,
|
|
198
|
+
bool verbatim);
|
|
199
|
+
|
|
200
|
+
SET_NO_MEMORY_INFO()
|
|
201
|
+
SET_MEMORY_INFO_NAME(GetAddrInfoReqWrap)
|
|
202
|
+
SET_SELF_SIZE(GetAddrInfoReqWrap)
|
|
203
|
+
|
|
204
|
+
bool verbatim() const { return verbatim_; }
|
|
205
|
+
|
|
206
|
+
private:
|
|
207
|
+
const bool verbatim_;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
class GetNameInfoReqWrap final : public ReqWrap<uv_getnameinfo_t> {
|
|
211
|
+
public:
|
|
212
|
+
GetNameInfoReqWrap(Environment* env, v8::Local<v8::Object> req_wrap_obj);
|
|
213
|
+
|
|
214
|
+
SET_NO_MEMORY_INFO()
|
|
215
|
+
SET_MEMORY_INFO_NAME(GetNameInfoReqWrap)
|
|
216
|
+
SET_SELF_SIZE(GetNameInfoReqWrap)
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
struct ResponseData final {
|
|
220
|
+
int status;
|
|
221
|
+
bool is_host;
|
|
222
|
+
SafeHostEntPointer host;
|
|
223
|
+
MallocedBuffer<unsigned char> buf;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
template <typename Traits>
|
|
227
|
+
class QueryWrap final : public AsyncWrap {
|
|
228
|
+
public:
|
|
229
|
+
QueryWrap(ChannelWrap* channel, v8::Local<v8::Object> req_wrap_obj)
|
|
230
|
+
: AsyncWrap(channel->env(), req_wrap_obj, AsyncWrap::PROVIDER_QUERYWRAP),
|
|
231
|
+
channel_(channel),
|
|
232
|
+
trace_name_(Traits::name) {}
|
|
233
|
+
|
|
234
|
+
~QueryWrap() {
|
|
235
|
+
CHECK_EQ(false, persistent().IsEmpty());
|
|
236
|
+
|
|
237
|
+
// Let Callback() know that this object no longer exists.
|
|
238
|
+
if (callback_ptr_ != nullptr)
|
|
239
|
+
*callback_ptr_ = nullptr;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
int Send(const char* name) {
|
|
243
|
+
return Traits::Send(this, name);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
void AresQuery(const char* name, int dnsclass, int type) {
|
|
247
|
+
channel_->EnsureServers();
|
|
248
|
+
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(
|
|
249
|
+
TRACING_CATEGORY_NODE2(dns, native), trace_name_, this,
|
|
250
|
+
"name", TRACE_STR_COPY(name));
|
|
251
|
+
ares_query(
|
|
252
|
+
channel_->cares_channel(),
|
|
253
|
+
name,
|
|
254
|
+
dnsclass,
|
|
255
|
+
type,
|
|
256
|
+
Callback,
|
|
257
|
+
MakeCallbackPointer());
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
void ParseError(int status) {
|
|
261
|
+
CHECK_NE(status, ARES_SUCCESS);
|
|
262
|
+
v8::HandleScope handle_scope(env()->isolate());
|
|
263
|
+
v8::Context::Scope context_scope(env()->context());
|
|
264
|
+
const char* code = ToErrorCodeString(status);
|
|
265
|
+
v8::Local<v8::Value> arg = OneByteString(env()->isolate(), code);
|
|
266
|
+
TRACE_EVENT_NESTABLE_ASYNC_END1(
|
|
267
|
+
TRACING_CATEGORY_NODE2(dns, native), trace_name_, this,
|
|
268
|
+
"error", status);
|
|
269
|
+
MakeCallback(env()->oncomplete_string(), 1, &arg);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const BaseObjectPtr<ChannelWrap>& channel() const { return channel_; }
|
|
273
|
+
|
|
274
|
+
void AfterResponse() {
|
|
275
|
+
CHECK(response_data_);
|
|
276
|
+
|
|
277
|
+
int status = response_data_->status;
|
|
278
|
+
|
|
279
|
+
if (status != ARES_SUCCESS)
|
|
280
|
+
return ParseError(status);
|
|
281
|
+
|
|
282
|
+
status = Traits::Parse(this, response_data_);
|
|
283
|
+
|
|
284
|
+
if (status != ARES_SUCCESS)
|
|
285
|
+
ParseError(status);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
void* MakeCallbackPointer() {
|
|
289
|
+
CHECK_NULL(callback_ptr_);
|
|
290
|
+
callback_ptr_ = new QueryWrap<Traits>*(this);
|
|
291
|
+
return callback_ptr_;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
static QueryWrap<Traits>* FromCallbackPointer(void* arg) {
|
|
295
|
+
std::unique_ptr<QueryWrap<Traits>*> wrap_ptr {
|
|
296
|
+
static_cast<QueryWrap<Traits>**>(arg)
|
|
297
|
+
};
|
|
298
|
+
QueryWrap<Traits>* wrap = *wrap_ptr.get();
|
|
299
|
+
if (wrap == nullptr) return nullptr;
|
|
300
|
+
wrap->callback_ptr_ = nullptr;
|
|
301
|
+
return wrap;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
static void Callback(
|
|
305
|
+
void* arg,
|
|
306
|
+
int status,
|
|
307
|
+
int timeouts,
|
|
308
|
+
unsigned char* answer_buf,
|
|
309
|
+
int answer_len) {
|
|
310
|
+
QueryWrap<Traits>* wrap = FromCallbackPointer(arg);
|
|
311
|
+
if (wrap == nullptr) return;
|
|
312
|
+
|
|
313
|
+
unsigned char* buf_copy = nullptr;
|
|
314
|
+
if (status == ARES_SUCCESS) {
|
|
315
|
+
buf_copy = node::Malloc<unsigned char>(answer_len);
|
|
316
|
+
memcpy(buf_copy, answer_buf, answer_len);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
wrap->response_data_ = std::make_unique<ResponseData>();
|
|
320
|
+
ResponseData* data = wrap->response_data_.get();
|
|
321
|
+
data->status = status;
|
|
322
|
+
data->is_host = false;
|
|
323
|
+
data->buf = MallocedBuffer<unsigned char>(buf_copy, answer_len);
|
|
324
|
+
|
|
325
|
+
wrap->QueueResponseCallback(status);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
static void Callback(
|
|
329
|
+
void* arg,
|
|
330
|
+
int status,
|
|
331
|
+
int timeouts,
|
|
332
|
+
struct hostent* host) {
|
|
333
|
+
QueryWrap<Traits>* wrap = FromCallbackPointer(arg);
|
|
334
|
+
if (wrap == nullptr) return;
|
|
335
|
+
|
|
336
|
+
struct hostent* host_copy = nullptr;
|
|
337
|
+
if (status == ARES_SUCCESS) {
|
|
338
|
+
host_copy = node::Malloc<hostent>(1);
|
|
339
|
+
cares_wrap_hostent_cpy(host_copy, host);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
wrap->response_data_ = std::make_unique<ResponseData>();
|
|
343
|
+
ResponseData* data = wrap->response_data_.get();
|
|
344
|
+
data->status = status;
|
|
345
|
+
data->host.reset(host_copy);
|
|
346
|
+
data->is_host = true;
|
|
347
|
+
|
|
348
|
+
wrap->QueueResponseCallback(status);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
void QueueResponseCallback(int status) {
|
|
352
|
+
BaseObjectPtr<QueryWrap<Traits>> strong_ref{this};
|
|
353
|
+
env()->SetImmediate([this, strong_ref](Environment*) {
|
|
354
|
+
AfterResponse();
|
|
355
|
+
|
|
356
|
+
// Delete once strong_ref goes out of scope.
|
|
357
|
+
Detach();
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
channel_->set_query_last_ok(status != ARES_ECONNREFUSED);
|
|
361
|
+
channel_->ModifyActivityQueryCount(-1);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
void CallOnComplete(
|
|
365
|
+
v8::Local<v8::Value> answer,
|
|
366
|
+
v8::Local<v8::Value> extra = v8::Local<v8::Value>()) {
|
|
367
|
+
v8::HandleScope handle_scope(env()->isolate());
|
|
368
|
+
v8::Context::Scope context_scope(env()->context());
|
|
369
|
+
v8::Local<v8::Value> argv[] = {
|
|
370
|
+
v8::Integer::New(env()->isolate(), 0),
|
|
371
|
+
answer,
|
|
372
|
+
extra
|
|
373
|
+
};
|
|
374
|
+
const int argc = arraysize(argv) - extra.IsEmpty();
|
|
375
|
+
TRACE_EVENT_NESTABLE_ASYNC_END0(
|
|
376
|
+
TRACING_CATEGORY_NODE2(dns, native), trace_name_, this);
|
|
377
|
+
|
|
378
|
+
MakeCallback(env()->oncomplete_string(), argc, argv);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
void MemoryInfo(MemoryTracker* tracker) const override {
|
|
382
|
+
tracker->TrackField("channel", channel_);
|
|
383
|
+
if (response_data_) {
|
|
384
|
+
tracker->TrackFieldWithSize("response", response_data_->buf.size);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
SET_MEMORY_INFO_NAME(QueryWrap)
|
|
389
|
+
SET_SELF_SIZE(QueryWrap<Traits>)
|
|
390
|
+
|
|
391
|
+
private:
|
|
392
|
+
BaseObjectPtr<ChannelWrap> channel_;
|
|
393
|
+
|
|
394
|
+
std::unique_ptr<ResponseData> response_data_;
|
|
395
|
+
const char* trace_name_;
|
|
396
|
+
// Pointer to pointer to 'this' that can be reset from the destructor,
|
|
397
|
+
// in order to let Callback() know that 'this' no longer exists.
|
|
398
|
+
QueryWrap<Traits>** callback_ptr_ = nullptr;
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
struct AnyTraits final {
|
|
402
|
+
static constexpr const char* name = "resolveAny";
|
|
403
|
+
static int Send(QueryWrap<AnyTraits>* wrap, const char* name);
|
|
404
|
+
static int Parse(
|
|
405
|
+
QueryWrap<AnyTraits>* wrap,
|
|
406
|
+
const std::unique_ptr<ResponseData>& response);
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
struct ATraits final {
|
|
410
|
+
static constexpr const char* name = "resolve4";
|
|
411
|
+
static int Send(QueryWrap<ATraits>* wrap, const char* name);
|
|
412
|
+
static int Parse(
|
|
413
|
+
QueryWrap<ATraits>* wrap,
|
|
414
|
+
const std::unique_ptr<ResponseData>& response);
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
struct AaaaTraits final {
|
|
418
|
+
static constexpr const char* name = "resolve6";
|
|
419
|
+
static int Send(QueryWrap<AaaaTraits>* wrap, const char* name);
|
|
420
|
+
static int Parse(
|
|
421
|
+
QueryWrap<AaaaTraits>* wrap,
|
|
422
|
+
const std::unique_ptr<ResponseData>& response);
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
struct CaaTraits final {
|
|
426
|
+
static constexpr const char* name = "resolveCaa";
|
|
427
|
+
static int Send(QueryWrap<CaaTraits>* wrap, const char* name);
|
|
428
|
+
static int Parse(
|
|
429
|
+
QueryWrap<CaaTraits>* wrap,
|
|
430
|
+
const std::unique_ptr<ResponseData>& response);
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
struct CnameTraits final {
|
|
434
|
+
static constexpr const char* name = "resolveCname";
|
|
435
|
+
static int Send(QueryWrap<CnameTraits>* wrap, const char* name);
|
|
436
|
+
static int Parse(
|
|
437
|
+
QueryWrap<CnameTraits>* wrap,
|
|
438
|
+
const std::unique_ptr<ResponseData>& response);
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
struct MxTraits final {
|
|
442
|
+
static constexpr const char* name = "resolveMx";
|
|
443
|
+
static int Send(QueryWrap<MxTraits>* wrap, const char* name);
|
|
444
|
+
static int Parse(
|
|
445
|
+
QueryWrap<MxTraits>* wrap,
|
|
446
|
+
const std::unique_ptr<ResponseData>& response);
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
struct NsTraits final {
|
|
450
|
+
static constexpr const char* name = "resolveNs";
|
|
451
|
+
static int Send(QueryWrap<NsTraits>* wrap, const char* name);
|
|
452
|
+
static int Parse(
|
|
453
|
+
QueryWrap<NsTraits>* wrap,
|
|
454
|
+
const std::unique_ptr<ResponseData>& response);
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
struct TxtTraits final {
|
|
458
|
+
static constexpr const char* name = "resolveTxt";
|
|
459
|
+
static int Send(QueryWrap<TxtTraits>* wrap, const char* name);
|
|
460
|
+
static int Parse(
|
|
461
|
+
QueryWrap<TxtTraits>* wrap,
|
|
462
|
+
const std::unique_ptr<ResponseData>& response);
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
struct SrvTraits final {
|
|
466
|
+
static constexpr const char* name = "resolveSrv";
|
|
467
|
+
static int Send(QueryWrap<SrvTraits>* wrap, const char* name);
|
|
468
|
+
static int Parse(
|
|
469
|
+
QueryWrap<SrvTraits>* wrap,
|
|
470
|
+
const std::unique_ptr<ResponseData>& response);
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
struct PtrTraits final {
|
|
474
|
+
static constexpr const char* name = "resolvePtr";
|
|
475
|
+
static int Send(QueryWrap<PtrTraits>* wrap, const char* name);
|
|
476
|
+
static int Parse(
|
|
477
|
+
QueryWrap<PtrTraits>* wrap,
|
|
478
|
+
const std::unique_ptr<ResponseData>& response);
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
struct NaptrTraits final {
|
|
482
|
+
static constexpr const char* name = "resolveNaptr";
|
|
483
|
+
static int Send(QueryWrap<NaptrTraits>* wrap, const char* name);
|
|
484
|
+
static int Parse(
|
|
485
|
+
QueryWrap<NaptrTraits>* wrap,
|
|
486
|
+
const std::unique_ptr<ResponseData>& response);
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
struct SoaTraits final {
|
|
490
|
+
static constexpr const char* name = "resolveSoa";
|
|
491
|
+
static int Send(QueryWrap<SoaTraits>* wrap, const char* name);
|
|
492
|
+
static int Parse(
|
|
493
|
+
QueryWrap<SoaTraits>* wrap,
|
|
494
|
+
const std::unique_ptr<ResponseData>& response);
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
struct ReverseTraits final {
|
|
498
|
+
static constexpr const char* name = "reverse";
|
|
499
|
+
static int Send(QueryWrap<ReverseTraits>* wrap, const char* name);
|
|
500
|
+
static int Parse(
|
|
501
|
+
QueryWrap<ReverseTraits>* wrap,
|
|
502
|
+
const std::unique_ptr<ResponseData>& response);
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
using QueryAnyWrap = QueryWrap<AnyTraits>;
|
|
506
|
+
using QueryAWrap = QueryWrap<ATraits>;
|
|
507
|
+
using QueryAaaaWrap = QueryWrap<AaaaTraits>;
|
|
508
|
+
using QueryCaaWrap = QueryWrap<CaaTraits>;
|
|
509
|
+
using QueryCnameWrap = QueryWrap<CnameTraits>;
|
|
510
|
+
using QueryMxWrap = QueryWrap<MxTraits>;
|
|
511
|
+
using QueryNsWrap = QueryWrap<NsTraits>;
|
|
512
|
+
using QueryTxtWrap = QueryWrap<TxtTraits>;
|
|
513
|
+
using QuerySrvWrap = QueryWrap<SrvTraits>;
|
|
514
|
+
using QueryPtrWrap = QueryWrap<PtrTraits>;
|
|
515
|
+
using QueryNaptrWrap = QueryWrap<NaptrTraits>;
|
|
516
|
+
using QuerySoaWrap = QueryWrap<SoaTraits>;
|
|
517
|
+
using GetHostByAddrWrap = QueryWrap<ReverseTraits>;
|
|
518
|
+
|
|
519
|
+
} // namespace cares_wrap
|
|
520
|
+
} // namespace node
|
|
521
|
+
|
|
522
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
523
|
+
|
|
524
|
+
#endif // SRC_CARES_WRAP_H_
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// This is an auto generated file, please do not edit.
|
|
2
|
+
// Refer to tools/dep_updaters/update-cjs-module-lexer.sh
|
|
3
|
+
#ifndef SRC_CJS_MODULE_LEXER_VERSION_H_
|
|
4
|
+
#define SRC_CJS_MODULE_LEXER_VERSION_H_
|
|
5
|
+
#define CJS_MODULE_LEXER_VERSION "1.2.2"
|
|
6
|
+
#endif // SRC_CJS_MODULE_LEXER_VERSION_H_
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#ifndef SRC_CLEANUP_QUEUE_INL_H_
|
|
2
|
+
#define SRC_CLEANUP_QUEUE_INL_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "base_object.h"
|
|
7
|
+
#include "cleanup_queue.h"
|
|
8
|
+
#include "memory_tracker-inl.h"
|
|
9
|
+
#include "util.h"
|
|
10
|
+
|
|
11
|
+
namespace node {
|
|
12
|
+
|
|
13
|
+
inline void CleanupQueue::MemoryInfo(MemoryTracker* tracker) const {
|
|
14
|
+
ForEachBaseObject([&](BaseObject* obj) {
|
|
15
|
+
if (obj->IsDoneInitializing()) tracker->Track(obj);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
inline size_t CleanupQueue::SelfSize() const {
|
|
20
|
+
return sizeof(CleanupQueue) +
|
|
21
|
+
cleanup_hooks_.size() * sizeof(CleanupHookCallback);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
bool CleanupQueue::empty() const {
|
|
25
|
+
return cleanup_hooks_.empty();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void CleanupQueue::Add(Callback cb, void* arg) {
|
|
29
|
+
auto insertion_info =
|
|
30
|
+
cleanup_hooks_.emplace(cb, arg, cleanup_hook_counter_++);
|
|
31
|
+
// Make sure there was no existing element with these values.
|
|
32
|
+
CHECK_EQ(insertion_info.second, true);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
void CleanupQueue::Remove(Callback cb, void* arg) {
|
|
36
|
+
CleanupHookCallback search{cb, arg, 0};
|
|
37
|
+
cleanup_hooks_.erase(search);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
template <typename T>
|
|
41
|
+
void CleanupQueue::ForEachBaseObject(T&& iterator) const {
|
|
42
|
+
std::vector<CleanupHookCallback> callbacks = GetOrdered();
|
|
43
|
+
|
|
44
|
+
for (const auto& hook : callbacks) {
|
|
45
|
+
BaseObject* obj = GetBaseObject(hook);
|
|
46
|
+
if (obj != nullptr) iterator(obj);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
BaseObject* CleanupQueue::GetBaseObject(
|
|
51
|
+
const CleanupHookCallback& callback) const {
|
|
52
|
+
if (callback.fn_ == BaseObject::DeleteMe)
|
|
53
|
+
return static_cast<BaseObject*>(callback.arg_);
|
|
54
|
+
else
|
|
55
|
+
return nullptr;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
} // namespace node
|
|
59
|
+
|
|
60
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
61
|
+
|
|
62
|
+
#endif // SRC_CLEANUP_QUEUE_INL_H_
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#ifndef SRC_CLEANUP_QUEUE_H_
|
|
2
|
+
#define SRC_CLEANUP_QUEUE_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include <cstddef>
|
|
7
|
+
#include <cstdint>
|
|
8
|
+
#include <unordered_set>
|
|
9
|
+
#include <vector>
|
|
10
|
+
|
|
11
|
+
#include "memory_tracker.h"
|
|
12
|
+
|
|
13
|
+
namespace node {
|
|
14
|
+
|
|
15
|
+
class BaseObject;
|
|
16
|
+
|
|
17
|
+
class CleanupQueue : public MemoryRetainer {
|
|
18
|
+
public:
|
|
19
|
+
typedef void (*Callback)(void*);
|
|
20
|
+
|
|
21
|
+
CleanupQueue() = default;
|
|
22
|
+
|
|
23
|
+
// Not copyable.
|
|
24
|
+
CleanupQueue(const CleanupQueue&) = delete;
|
|
25
|
+
|
|
26
|
+
SET_MEMORY_INFO_NAME(CleanupQueue)
|
|
27
|
+
inline void MemoryInfo(node::MemoryTracker* tracker) const override;
|
|
28
|
+
inline size_t SelfSize() const override;
|
|
29
|
+
|
|
30
|
+
inline bool empty() const;
|
|
31
|
+
|
|
32
|
+
inline void Add(Callback cb, void* arg);
|
|
33
|
+
inline void Remove(Callback cb, void* arg);
|
|
34
|
+
void Drain();
|
|
35
|
+
|
|
36
|
+
template <typename T>
|
|
37
|
+
inline void ForEachBaseObject(T&& iterator) const;
|
|
38
|
+
|
|
39
|
+
private:
|
|
40
|
+
class CleanupHookCallback {
|
|
41
|
+
public:
|
|
42
|
+
CleanupHookCallback(Callback fn,
|
|
43
|
+
void* arg,
|
|
44
|
+
uint64_t insertion_order_counter)
|
|
45
|
+
: fn_(fn),
|
|
46
|
+
arg_(arg),
|
|
47
|
+
insertion_order_counter_(insertion_order_counter) {}
|
|
48
|
+
|
|
49
|
+
// Only hashes `arg_`, since that is usually enough to identify the hook.
|
|
50
|
+
struct Hash {
|
|
51
|
+
size_t operator()(const CleanupHookCallback& cb) const;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Compares by `fn_` and `arg_` being equal.
|
|
55
|
+
struct Equal {
|
|
56
|
+
bool operator()(const CleanupHookCallback& a,
|
|
57
|
+
const CleanupHookCallback& b) const;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
private:
|
|
61
|
+
friend class CleanupQueue;
|
|
62
|
+
Callback fn_;
|
|
63
|
+
void* arg_;
|
|
64
|
+
|
|
65
|
+
// We keep track of the insertion order for these objects, so that we can
|
|
66
|
+
// call the callbacks in reverse order when we are cleaning up.
|
|
67
|
+
uint64_t insertion_order_counter_;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
std::vector<CleanupHookCallback> GetOrdered() const;
|
|
71
|
+
inline BaseObject* GetBaseObject(const CleanupHookCallback& callback) const;
|
|
72
|
+
|
|
73
|
+
// Use an unordered_set, so that we have efficient insertion and removal.
|
|
74
|
+
std::unordered_set<CleanupHookCallback,
|
|
75
|
+
CleanupHookCallback::Hash,
|
|
76
|
+
CleanupHookCallback::Equal>
|
|
77
|
+
cleanup_hooks_;
|
|
78
|
+
uint64_t cleanup_hook_counter_ = 0;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
} // namespace node
|
|
82
|
+
|
|
83
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
84
|
+
|
|
85
|
+
#endif // SRC_CLEANUP_QUEUE_H_
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef SRC_CONNECT_WRAP_H_
|
|
2
|
+
#define SRC_CONNECT_WRAP_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "req_wrap-inl.h"
|
|
7
|
+
#include "async_wrap.h"
|
|
8
|
+
|
|
9
|
+
namespace node {
|
|
10
|
+
|
|
11
|
+
class ConnectWrap : public ReqWrap<uv_connect_t> {
|
|
12
|
+
public:
|
|
13
|
+
ConnectWrap(Environment* env,
|
|
14
|
+
v8::Local<v8::Object> req_wrap_obj,
|
|
15
|
+
AsyncWrap::ProviderType provider);
|
|
16
|
+
|
|
17
|
+
SET_NO_MEMORY_INFO()
|
|
18
|
+
SET_MEMORY_INFO_NAME(ConnectWrap)
|
|
19
|
+
SET_SELF_SIZE(ConnectWrap)
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
} // namespace node
|
|
23
|
+
|
|
24
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
25
|
+
|
|
26
|
+
#endif // SRC_CONNECT_WRAP_H_
|