@kungfu-tech/libnode-win32-x64 0.0.0-bootstrap.0 → 22.22.3-kf.1
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/LICENSE +201 -0
- package/README.md +3 -0
- package/dist/node/include/acorn_version.h +6 -0
- package/dist/node/include/aliased_buffer-inl.h +244 -0
- package/dist/node/include/aliased_buffer.h +206 -0
- package/dist/node/include/aliased_struct-inl.h +54 -0
- package/dist/node/include/aliased_struct.h +63 -0
- package/dist/node/include/amaro_version.h +6 -0
- package/dist/node/include/async_context_frame.h +33 -0
- package/dist/node/include/async_wrap-inl.h +96 -0
- package/dist/node/include/async_wrap.h +243 -0
- package/dist/node/include/base_object-inl.h +335 -0
- package/dist/node/include/base_object.h +342 -0
- package/dist/node/include/base_object_types.h +74 -0
- package/dist/node/include/blob_serializer_deserializer-inl.h +385 -0
- package/dist/node/include/blob_serializer_deserializer.h +132 -0
- package/dist/node/include/callback_queue-inl.h +97 -0
- package/dist/node/include/callback_queue.h +79 -0
- package/dist/node/include/cares_wrap.h +447 -0
- package/dist/node/include/cjs_module_lexer_version.h +6 -0
- package/dist/node/include/cleanup_queue-inl.h +36 -0
- package/dist/node/include/cleanup_queue.h +79 -0
- package/dist/node/include/compile_cache.h +104 -0
- package/dist/node/include/connect_wrap.h +26 -0
- package/dist/node/include/connection_wrap.h +30 -0
- package/dist/node/include/cppgc/allocation.h +310 -0
- package/dist/node/include/cppgc/common.h +28 -0
- package/dist/node/include/cppgc/cross-thread-persistent.h +466 -0
- package/dist/node/include/cppgc/custom-space.h +97 -0
- package/dist/node/include/cppgc/default-platform.h +67 -0
- package/dist/node/include/cppgc/ephemeron-pair.h +30 -0
- package/dist/node/include/cppgc/explicit-management.h +100 -0
- package/dist/node/include/cppgc/garbage-collected.h +106 -0
- package/dist/node/include/cppgc/heap-consistency.h +309 -0
- package/dist/node/include/cppgc/heap-handle.h +48 -0
- package/dist/node/include/cppgc/heap-state.h +82 -0
- package/dist/node/include/cppgc/heap-statistics.h +120 -0
- package/dist/node/include/cppgc/heap.h +202 -0
- package/dist/node/include/cppgc/internal/api-constants.h +87 -0
- package/dist/node/include/cppgc/internal/atomic-entry-flag.h +48 -0
- package/dist/node/include/cppgc/internal/base-page-handle.h +45 -0
- package/dist/node/include/cppgc/internal/caged-heap-local-data.h +121 -0
- package/dist/node/include/cppgc/internal/caged-heap.h +68 -0
- package/dist/node/include/cppgc/internal/compiler-specific.h +38 -0
- package/dist/node/include/cppgc/internal/finalizer-trait.h +93 -0
- package/dist/node/include/cppgc/internal/gc-info.h +148 -0
- package/dist/node/include/cppgc/internal/logging.h +50 -0
- package/dist/node/include/cppgc/internal/member-storage.h +256 -0
- package/dist/node/include/cppgc/internal/name-trait.h +137 -0
- package/dist/node/include/cppgc/internal/persistent-node.h +214 -0
- package/dist/node/include/cppgc/internal/pointer-policies.h +243 -0
- package/dist/node/include/cppgc/internal/write-barrier.h +487 -0
- package/dist/node/include/cppgc/liveness-broker.h +78 -0
- package/dist/node/include/cppgc/macros.h +35 -0
- package/dist/node/include/cppgc/member.h +629 -0
- package/dist/node/include/cppgc/name-provider.h +65 -0
- package/dist/node/include/cppgc/object-size-trait.h +58 -0
- package/dist/node/include/cppgc/persistent.h +377 -0
- package/dist/node/include/cppgc/platform.h +163 -0
- package/dist/node/include/cppgc/prefinalizer.h +75 -0
- package/dist/node/include/cppgc/process-heap-statistics.h +36 -0
- package/dist/node/include/cppgc/sentinel-pointer.h +39 -0
- package/dist/node/include/cppgc/source-location.h +16 -0
- package/dist/node/include/cppgc/testing.h +106 -0
- package/dist/node/include/cppgc/trace-trait.h +128 -0
- package/dist/node/include/cppgc/type-traits.h +271 -0
- package/dist/node/include/cppgc/visitor.h +504 -0
- package/dist/node/include/crypto/crypto_aes.h +88 -0
- package/dist/node/include/crypto/crypto_bio.h +193 -0
- package/dist/node/include/crypto/crypto_cipher.h +293 -0
- package/dist/node/include/crypto/crypto_clienthello-inl.h +90 -0
- package/dist/node/include/crypto/crypto_clienthello.h +131 -0
- package/dist/node/include/crypto/crypto_common.h +64 -0
- package/dist/node/include/crypto/crypto_context.h +171 -0
- package/dist/node/include/crypto/crypto_dh.h +126 -0
- package/dist/node/include/crypto/crypto_dsa.h +52 -0
- package/dist/node/include/crypto/crypto_ec.h +164 -0
- package/dist/node/include/crypto/crypto_hash.h +91 -0
- package/dist/node/include/crypto/crypto_hkdf.h +61 -0
- package/dist/node/include/crypto/crypto_hmac.h +92 -0
- package/dist/node/include/crypto/crypto_keygen.h +299 -0
- package/dist/node/include/crypto/crypto_keys.h +392 -0
- package/dist/node/include/crypto/crypto_pbkdf2.h +74 -0
- package/dist/node/include/crypto/crypto_random.h +124 -0
- package/dist/node/include/crypto/crypto_rsa.h +136 -0
- package/dist/node/include/crypto/crypto_scrypt.h +85 -0
- package/dist/node/include/crypto/crypto_sig.h +165 -0
- package/dist/node/include/crypto/crypto_spkac.h +21 -0
- package/dist/node/include/crypto/crypto_timing.h +20 -0
- package/dist/node/include/crypto/crypto_tls.h +305 -0
- package/dist/node/include/crypto/crypto_util.h +725 -0
- package/dist/node/include/crypto/crypto_x509.h +140 -0
- package/dist/node/include/dataqueue/queue.h +306 -0
- package/dist/node/include/debug_utils-inl.h +278 -0
- package/dist/node/include/debug_utils.h +196 -0
- package/dist/node/include/diagnosticfilename-inl.h +33 -0
- package/dist/node/include/embedded_data.h +17 -0
- package/dist/node/include/encoding_binding.h +61 -0
- package/dist/node/include/env-inl.h +984 -0
- package/dist/node/include/env.h +1287 -0
- package/dist/node/include/env_properties.h +540 -0
- package/dist/node/include/handle_wrap.h +123 -0
- package/dist/node/include/histogram-inl.h +107 -0
- package/dist/node/include/histogram.h +279 -0
- package/dist/node/include/inspector/io_agent.h +30 -0
- package/dist/node/include/inspector/main_thread_interface.h +116 -0
- package/dist/node/include/inspector/network_agent.h +94 -0
- package/dist/node/include/inspector/network_inspector.h +45 -0
- package/dist/node/include/inspector/network_requests_buffer.h +195 -0
- package/dist/node/include/inspector/network_resource_manager.h +29 -0
- package/dist/node/include/inspector/node_json.h +24 -0
- package/dist/node/include/inspector/node_string.h +101 -0
- package/dist/node/include/inspector/protocol_helper.h +27 -0
- package/dist/node/include/inspector/runtime_agent.h +41 -0
- package/dist/node/include/inspector/target_agent.h +75 -0
- package/dist/node/include/inspector/tracing_agent.h +43 -0
- package/dist/node/include/inspector/worker_agent.h +40 -0
- package/dist/node/include/inspector/worker_inspector.h +124 -0
- package/dist/node/include/inspector_agent.h +165 -0
- package/dist/node/include/inspector_io.h +78 -0
- package/dist/node/include/inspector_profiler.h +149 -0
- package/dist/node/include/inspector_socket.h +60 -0
- package/dist/node/include/inspector_socket_server.h +110 -0
- package/dist/node/include/js_native_api.h +607 -0
- package/dist/node/include/js_native_api_types.h +226 -0
- package/dist/node/include/js_native_api_v8.h +485 -0
- package/dist/node/include/js_native_api_v8_internals.h +45 -0
- package/dist/node/include/js_stream.h +52 -0
- package/dist/node/include/json_utils.h +172 -0
- package/dist/node/include/large_pages/node_large_page.h +34 -0
- package/dist/node/include/libplatform/libplatform-export.h +29 -0
- package/dist/node/include/libplatform/libplatform.h +112 -0
- package/dist/node/include/libplatform/v8-tracing.h +333 -0
- package/dist/node/include/memory_tracker-inl.h +359 -0
- package/dist/node/include/memory_tracker.h +289 -0
- package/dist/node/include/module_wrap.h +216 -0
- package/dist/node/include/node.h +1593 -0
- package/dist/node/include/node_api.h +265 -0
- package/dist/node/include/node_api_internals.h +48 -0
- package/dist/node/include/node_api_types.h +56 -0
- package/dist/node/include/node_binding.h +161 -0
- package/dist/node/include/node_blob.h +159 -0
- package/dist/node/include/node_bob-inl.h +36 -0
- package/dist/node/include/node_bob.h +107 -0
- package/dist/node/include/node_buffer.h +92 -0
- package/dist/node/include/node_builtins.h +220 -0
- package/dist/node/include/node_config_file.h +46 -0
- package/dist/node/include/node_constants.h +82 -0
- package/dist/node/include/node_context_data.h +168 -0
- package/dist/node/include/node_contextify.h +204 -0
- package/dist/node/include/node_crypto.h +56 -0
- package/dist/node/include/node_debug.h +30 -0
- package/dist/node/include/node_dir.h +52 -0
- package/dist/node/include/node_dotenv.h +45 -0
- package/dist/node/include/node_errors.h +380 -0
- package/dist/node/include/node_exit_code.h +54 -0
- package/dist/node/include/node_external_reference.h +165 -0
- package/dist/node/include/node_file-inl.h +406 -0
- package/dist/node/include/node_file.h +537 -0
- package/dist/node/include/node_http2.h +1177 -0
- package/dist/node/include/node_http2_state.h +159 -0
- package/dist/node/include/node_http_common-inl.h +202 -0
- package/dist/node/include/node_http_common.h +535 -0
- package/dist/node/include/node_i18n.h +132 -0
- package/dist/node/include/node_internals.h +483 -0
- package/dist/node/include/node_main_instance.h +67 -0
- package/dist/node/include/node_mem-inl.h +113 -0
- package/dist/node/include/node_mem.h +45 -0
- package/dist/node/include/node_messaging.h +389 -0
- package/dist/node/include/node_metadata.h +164 -0
- package/dist/node/include/node_modules.h +91 -0
- package/dist/node/include/node_mutex.h +323 -0
- package/dist/node/include/node_object_wrap.h +132 -0
- package/dist/node/include/node_options-inl.h +490 -0
- package/dist/node/include/node_options.h +615 -0
- package/dist/node/include/node_perf.h +166 -0
- package/dist/node/include/node_perf_common.h +102 -0
- package/dist/node/include/node_platform.h +238 -0
- package/dist/node/include/node_process-inl.h +26 -0
- package/dist/node/include/node_process.h +112 -0
- package/dist/node/include/node_realm-inl.h +151 -0
- package/dist/node/include/node_realm.h +183 -0
- package/dist/node/include/node_report.h +43 -0
- package/dist/node/include/node_revert.h +82 -0
- package/dist/node/include/node_root_certs.h +3520 -0
- package/dist/node/include/node_sea.h +74 -0
- package/dist/node/include/node_shadow_realm.h +46 -0
- package/dist/node/include/node_snapshot_builder.h +57 -0
- package/dist/node/include/node_snapshotable.h +174 -0
- package/dist/node/include/node_sockaddr-inl.h +257 -0
- package/dist/node/include/node_sockaddr.h +394 -0
- package/dist/node/include/node_sqlite.h +270 -0
- package/dist/node/include/node_stat_watcher.h +73 -0
- package/dist/node/include/node_task_runner.h +92 -0
- package/dist/node/include/node_threadsafe_cow-inl.h +54 -0
- package/dist/node/include/node_threadsafe_cow.h +105 -0
- package/dist/node/include/node_union_bytes.h +81 -0
- package/dist/node/include/node_url.h +96 -0
- package/dist/node/include/node_v8.h +77 -0
- package/dist/node/include/node_v8_platform-inl.h +185 -0
- package/dist/node/include/node_version.h +110 -0
- package/dist/node/include/node_wasi.h +184 -0
- package/dist/node/include/node_wasm_web_api.h +55 -0
- package/dist/node/include/node_watchdog.h +154 -0
- package/dist/node/include/node_webstorage.h +60 -0
- package/dist/node/include/node_worker.h +158 -0
- package/dist/node/include/path.h +33 -0
- package/dist/node/include/permission/addon_permission.h +31 -0
- package/dist/node/include/permission/child_process_permission.h +31 -0
- package/dist/node/include/permission/fs_permission.h +167 -0
- package/dist/node/include/permission/inspector_permission.h +31 -0
- package/dist/node/include/permission/permission.h +138 -0
- package/dist/node/include/permission/permission_base.h +65 -0
- package/dist/node/include/permission/wasi_permission.h +31 -0
- package/dist/node/include/permission/worker_permission.h +31 -0
- package/dist/node/include/pipe_wrap.h +80 -0
- package/dist/node/include/quic/application.h +159 -0
- package/dist/node/include/quic/bindingdata.h +272 -0
- package/dist/node/include/quic/cid.h +127 -0
- package/dist/node/include/quic/data.h +148 -0
- package/dist/node/include/quic/defs.h +245 -0
- package/dist/node/include/quic/endpoint.h +458 -0
- package/dist/node/include/quic/http3.h +15 -0
- package/dist/node/include/quic/logstream.h +81 -0
- package/dist/node/include/quic/packet.h +152 -0
- package/dist/node/include/quic/preferredaddress.h +72 -0
- package/dist/node/include/quic/session.h +443 -0
- package/dist/node/include/quic/sessionticket.h +108 -0
- package/dist/node/include/quic/streams.h +232 -0
- package/dist/node/include/quic/tlscontext.h +227 -0
- package/dist/node/include/quic/tokens.h +256 -0
- package/dist/node/include/quic/transportparams.h +165 -0
- package/dist/node/include/req_wrap-inl.h +171 -0
- package/dist/node/include/req_wrap.h +77 -0
- package/dist/node/include/spawn_sync.h +243 -0
- package/dist/node/include/stream_base-inl.h +173 -0
- package/dist/node/include/stream_base.h +478 -0
- package/dist/node/include/stream_pipe.h +76 -0
- package/dist/node/include/stream_wrap.h +132 -0
- package/dist/node/include/string_bytes.h +113 -0
- package/dist/node/include/string_decoder-inl.h +31 -0
- package/dist/node/include/string_decoder.h +49 -0
- package/dist/node/include/tcp_wrap.h +105 -0
- package/dist/node/include/threadpoolwork-inl.h +70 -0
- package/dist/node/include/timer_wrap-inl.h +32 -0
- package/dist/node/include/timer_wrap.h +85 -0
- package/dist/node/include/timers.h +70 -0
- package/dist/node/include/tracing/agent.h +195 -0
- package/dist/node/include/tracing/node_trace_buffer.h +83 -0
- package/dist/node/include/tracing/node_trace_writer.h +75 -0
- package/dist/node/include/tracing/trace_event.h +722 -0
- package/dist/node/include/tracing/trace_event_common.h +1109 -0
- package/dist/node/include/tracing/traced_value.h +129 -0
- package/dist/node/include/tty_wrap.h +65 -0
- package/dist/node/include/udp_wrap.h +230 -0
- package/dist/node/include/undici_version.h +6 -0
- package/dist/node/include/util-inl.h +700 -0
- package/dist/node/include/util.h +1021 -0
- package/dist/node/include/uv/aix.h +32 -0
- package/dist/node/include/uv/bsd.h +34 -0
- package/dist/node/include/uv/darwin.h +61 -0
- package/dist/node/include/uv/errno.h +483 -0
- package/dist/node/include/uv/linux.h +34 -0
- package/dist/node/include/uv/os390.h +33 -0
- package/dist/node/include/uv/posix.h +31 -0
- package/dist/node/include/uv/sunos.h +44 -0
- package/dist/node/include/uv/threadpool.h +37 -0
- package/dist/node/include/uv/tree.h +521 -0
- package/dist/node/include/uv/unix.h +512 -0
- package/dist/node/include/uv/version.h +43 -0
- package/dist/node/include/uv/win.h +698 -0
- package/dist/node/include/uv.h +1990 -0
- package/dist/node/include/v8-array-buffer.h +525 -0
- package/dist/node/include/v8-callbacks.h +462 -0
- package/dist/node/include/v8-container.h +183 -0
- package/dist/node/include/v8-context.h +485 -0
- package/dist/node/include/v8-cppgc.h +245 -0
- package/dist/node/include/v8-data.h +80 -0
- package/dist/node/include/v8-date.h +48 -0
- package/dist/node/include/v8-debug.h +168 -0
- package/dist/node/include/v8-embedder-heap.h +82 -0
- package/dist/node/include/v8-embedder-state-scope.h +52 -0
- package/dist/node/include/v8-exception.h +223 -0
- package/dist/node/include/v8-extension.h +62 -0
- package/dist/node/include/v8-external.h +37 -0
- package/dist/node/include/v8-fast-api-calls.h +984 -0
- package/dist/node/include/v8-forward.h +82 -0
- package/dist/node/include/v8-function-callback.h +607 -0
- package/dist/node/include/v8-function.h +140 -0
- package/dist/node/include/v8-handle-base.h +137 -0
- package/dist/node/include/v8-initialization.h +289 -0
- package/dist/node/include/v8-inspector-protocol.h +13 -0
- package/dist/node/include/v8-inspector.h +419 -0
- package/dist/node/include/v8-internal.h +1397 -0
- package/dist/node/include/v8-isolate.h +1767 -0
- package/dist/node/include/v8-json.h +47 -0
- package/dist/node/include/v8-local-handle.h +758 -0
- package/dist/node/include/v8-locker.h +138 -0
- package/dist/node/include/v8-maybe.h +160 -0
- package/dist/node/include/v8-memory-span.h +198 -0
- package/dist/node/include/v8-message.h +233 -0
- package/dist/node/include/v8-metrics.h +264 -0
- package/dist/node/include/v8-microtask-queue.h +157 -0
- package/dist/node/include/v8-microtask.h +28 -0
- package/dist/node/include/v8-object.h +824 -0
- package/dist/node/include/v8-persistent-handle.h +582 -0
- package/dist/node/include/v8-platform.h +1358 -0
- package/dist/node/include/v8-primitive-object.h +118 -0
- package/dist/node/include/v8-primitive.h +877 -0
- package/dist/node/include/v8-profiler.h +1302 -0
- package/dist/node/include/v8-promise.h +174 -0
- package/dist/node/include/v8-proxy.h +50 -0
- package/dist/node/include/v8-regexp.h +106 -0
- package/dist/node/include/v8-script.h +904 -0
- package/dist/node/include/v8-snapshot.h +266 -0
- package/dist/node/include/v8-source-location.h +92 -0
- package/dist/node/include/v8-statistics.h +238 -0
- package/dist/node/include/v8-template.h +1297 -0
- package/dist/node/include/v8-traced-handle.h +432 -0
- package/dist/node/include/v8-typed-array.h +390 -0
- package/dist/node/include/v8-unwinder-state.h +31 -0
- package/dist/node/include/v8-unwinder.h +132 -0
- package/dist/node/include/v8-util.h +665 -0
- package/dist/node/include/v8-value-serializer-version.h +24 -0
- package/dist/node/include/v8-value-serializer.h +316 -0
- package/dist/node/include/v8-value.h +655 -0
- package/dist/node/include/v8-version-string.h +38 -0
- package/dist/node/include/v8-version.h +20 -0
- package/dist/node/include/v8-wasm-trap-handler-posix.h +31 -0
- package/dist/node/include/v8-wasm-trap-handler-win.h +28 -0
- package/dist/node/include/v8-wasm.h +201 -0
- package/dist/node/include/v8-weak-callback-info.h +80 -0
- package/dist/node/include/v8.h +88 -0
- package/dist/node/include/v8config.h +981 -0
- package/dist/node/include/zlib_version.h +6 -0
- package/dist/node/libnode.dll +0 -0
- package/dist/node/libnode.lib +0 -0
- package/dist/node/libnodebuildinfo.json +10 -0
- package/dist/node/link_node.lib +0 -0
- package/dist/node/link_node.node +0 -0
- package/index.js +5 -0
- package/libnode.release.json +8 -0
- package/package.json +29 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#ifndef SRC_CALLBACK_QUEUE_H_
|
|
2
|
+
#define SRC_CALLBACK_QUEUE_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include <atomic>
|
|
7
|
+
#include <memory>
|
|
8
|
+
|
|
9
|
+
namespace node {
|
|
10
|
+
|
|
11
|
+
namespace CallbackFlags {
|
|
12
|
+
enum Flags {
|
|
13
|
+
kUnrefed = 0,
|
|
14
|
+
kRefed = 1,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// A queue of C++ functions that take Args... as arguments and return R
|
|
19
|
+
// (this is similar to the signature of std::function).
|
|
20
|
+
// New entries are added using `CreateCallback()`/`Push()`, and removed using
|
|
21
|
+
// `Shift()`.
|
|
22
|
+
// The `refed` flag is left for easier use in situations in which some of these
|
|
23
|
+
// should be run even if nothing else is keeping the event loop alive.
|
|
24
|
+
template <typename R, typename... Args>
|
|
25
|
+
class CallbackQueue {
|
|
26
|
+
public:
|
|
27
|
+
class Callback {
|
|
28
|
+
public:
|
|
29
|
+
explicit inline Callback(CallbackFlags::Flags flags);
|
|
30
|
+
|
|
31
|
+
virtual ~Callback() = default;
|
|
32
|
+
virtual R Call(Args... args) = 0;
|
|
33
|
+
|
|
34
|
+
inline CallbackFlags::Flags flags() const;
|
|
35
|
+
|
|
36
|
+
private:
|
|
37
|
+
inline std::unique_ptr<Callback> get_next();
|
|
38
|
+
inline void set_next(std::unique_ptr<Callback> next);
|
|
39
|
+
|
|
40
|
+
CallbackFlags::Flags flags_;
|
|
41
|
+
std::unique_ptr<Callback> next_;
|
|
42
|
+
|
|
43
|
+
friend class CallbackQueue;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
template <typename Fn>
|
|
47
|
+
inline std::unique_ptr<Callback> CreateCallback(
|
|
48
|
+
Fn&& fn, CallbackFlags::Flags);
|
|
49
|
+
|
|
50
|
+
inline std::unique_ptr<Callback> Shift();
|
|
51
|
+
inline void Push(std::unique_ptr<Callback> cb);
|
|
52
|
+
// ConcatMove adds elements from 'other' to the end of this list, and clears
|
|
53
|
+
// 'other' afterwards.
|
|
54
|
+
inline void ConcatMove(CallbackQueue&& other);
|
|
55
|
+
|
|
56
|
+
// size() is atomic and may be called from any thread.
|
|
57
|
+
inline size_t size() const;
|
|
58
|
+
|
|
59
|
+
private:
|
|
60
|
+
template <typename Fn>
|
|
61
|
+
class CallbackImpl final : public Callback {
|
|
62
|
+
public:
|
|
63
|
+
CallbackImpl(Fn&& callback, CallbackFlags::Flags flags);
|
|
64
|
+
R Call(Args... args) override;
|
|
65
|
+
|
|
66
|
+
private:
|
|
67
|
+
Fn callback_;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
std::atomic<size_t> size_ {0};
|
|
71
|
+
std::unique_ptr<Callback> head_;
|
|
72
|
+
Callback* tail_ = nullptr;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace node
|
|
76
|
+
|
|
77
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
78
|
+
|
|
79
|
+
#endif // SRC_CALLBACK_QUEUE_H_
|
|
@@ -0,0 +1,447 @@
|
|
|
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
|
+
constexpr uint8_t DNS_ORDER_VERBATIM = 0;
|
|
34
|
+
constexpr uint8_t DNS_ORDER_IPV4_FIRST = 1;
|
|
35
|
+
constexpr uint8_t DNS_ORDER_IPV6_FIRST = 2;
|
|
36
|
+
|
|
37
|
+
class ChannelWrap;
|
|
38
|
+
|
|
39
|
+
inline void safe_free_hostent(struct hostent* host);
|
|
40
|
+
|
|
41
|
+
using HostEntPointer = DeleteFnPtr<hostent, ares_free_hostent>;
|
|
42
|
+
using SafeHostEntPointer = DeleteFnPtr<hostent, safe_free_hostent>;
|
|
43
|
+
|
|
44
|
+
inline const char* ToErrorCodeString(int status) {
|
|
45
|
+
switch (status) {
|
|
46
|
+
#define V(code) case ARES_##code: return #code;
|
|
47
|
+
V(EADDRGETNETWORKPARAMS)
|
|
48
|
+
V(EBADFAMILY)
|
|
49
|
+
V(EBADFLAGS)
|
|
50
|
+
V(EBADHINTS)
|
|
51
|
+
V(EBADNAME)
|
|
52
|
+
V(EBADQUERY)
|
|
53
|
+
V(EBADRESP)
|
|
54
|
+
V(EBADSTR)
|
|
55
|
+
V(ECANCELLED)
|
|
56
|
+
V(ECONNREFUSED)
|
|
57
|
+
V(EDESTRUCTION)
|
|
58
|
+
V(EFILE)
|
|
59
|
+
V(EFORMERR)
|
|
60
|
+
V(ELOADIPHLPAPI)
|
|
61
|
+
V(ENODATA)
|
|
62
|
+
V(ENOMEM)
|
|
63
|
+
V(ENONAME)
|
|
64
|
+
V(ENOTFOUND)
|
|
65
|
+
V(ENOTIMP)
|
|
66
|
+
V(ENOTINITIALIZED)
|
|
67
|
+
V(EOF)
|
|
68
|
+
V(EREFUSED)
|
|
69
|
+
V(ESERVFAIL)
|
|
70
|
+
V(ETIMEOUT)
|
|
71
|
+
#undef V
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return "UNKNOWN_ARES_ERROR";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
inline void cares_wrap_hostent_cpy(
|
|
78
|
+
struct hostent* dest,
|
|
79
|
+
const struct hostent* src) {
|
|
80
|
+
dest->h_addr_list = nullptr;
|
|
81
|
+
dest->h_addrtype = 0;
|
|
82
|
+
dest->h_aliases = nullptr;
|
|
83
|
+
dest->h_length = 0;
|
|
84
|
+
dest->h_name = nullptr;
|
|
85
|
+
|
|
86
|
+
/* copy `h_name` */
|
|
87
|
+
size_t name_size = strlen(src->h_name) + 1;
|
|
88
|
+
dest->h_name = node::Malloc<char>(name_size);
|
|
89
|
+
memcpy(dest->h_name, src->h_name, name_size);
|
|
90
|
+
|
|
91
|
+
/* copy `h_aliases` */
|
|
92
|
+
size_t alias_count;
|
|
93
|
+
for (alias_count = 0;
|
|
94
|
+
src->h_aliases[alias_count] != nullptr;
|
|
95
|
+
alias_count++) {
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
dest->h_aliases = node::Malloc<char*>(alias_count + 1);
|
|
99
|
+
for (size_t i = 0; i < alias_count; i++) {
|
|
100
|
+
const size_t cur_alias_size = strlen(src->h_aliases[i]) + 1;
|
|
101
|
+
dest->h_aliases[i] = node::Malloc(cur_alias_size);
|
|
102
|
+
memcpy(dest->h_aliases[i], src->h_aliases[i], cur_alias_size);
|
|
103
|
+
}
|
|
104
|
+
dest->h_aliases[alias_count] = nullptr;
|
|
105
|
+
|
|
106
|
+
/* copy `h_addr_list` */
|
|
107
|
+
size_t list_count;
|
|
108
|
+
for (list_count = 0;
|
|
109
|
+
src->h_addr_list[list_count] != nullptr;
|
|
110
|
+
list_count++) {
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
dest->h_addr_list = node::Malloc<char*>(list_count + 1);
|
|
114
|
+
for (size_t i = 0; i < list_count; i++) {
|
|
115
|
+
dest->h_addr_list[i] = node::Malloc(src->h_length);
|
|
116
|
+
memcpy(dest->h_addr_list[i], src->h_addr_list[i], src->h_length);
|
|
117
|
+
}
|
|
118
|
+
dest->h_addr_list[list_count] = nullptr;
|
|
119
|
+
|
|
120
|
+
/* work after work */
|
|
121
|
+
dest->h_length = src->h_length;
|
|
122
|
+
dest->h_addrtype = src->h_addrtype;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
struct NodeAresTask final : public MemoryRetainer {
|
|
127
|
+
ChannelWrap* channel;
|
|
128
|
+
ares_socket_t sock;
|
|
129
|
+
uv_poll_t poll_watcher;
|
|
130
|
+
|
|
131
|
+
inline void MemoryInfo(MemoryTracker* trakcer) const override;
|
|
132
|
+
SET_MEMORY_INFO_NAME(NodeAresTask)
|
|
133
|
+
SET_SELF_SIZE(NodeAresTask)
|
|
134
|
+
|
|
135
|
+
struct Hash {
|
|
136
|
+
inline size_t operator()(NodeAresTask* a) const {
|
|
137
|
+
return std::hash<ares_socket_t>()(a->sock);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
struct Equal {
|
|
142
|
+
inline bool operator()(NodeAresTask* a, NodeAresTask* b) const {
|
|
143
|
+
return a->sock == b->sock;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
static NodeAresTask* Create(ChannelWrap* channel, ares_socket_t sock);
|
|
148
|
+
|
|
149
|
+
using List = std::unordered_set<NodeAresTask*, Hash, Equal>;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
class ChannelWrap final : public AsyncWrap {
|
|
153
|
+
public:
|
|
154
|
+
ChannelWrap(Environment* env,
|
|
155
|
+
v8::Local<v8::Object> object,
|
|
156
|
+
int timeout,
|
|
157
|
+
int tries,
|
|
158
|
+
int max_timeout);
|
|
159
|
+
~ChannelWrap() override;
|
|
160
|
+
|
|
161
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
162
|
+
|
|
163
|
+
void Setup();
|
|
164
|
+
void EnsureServers();
|
|
165
|
+
void StartTimer();
|
|
166
|
+
void CloseTimer();
|
|
167
|
+
|
|
168
|
+
void ModifyActivityQueryCount(int count);
|
|
169
|
+
|
|
170
|
+
inline uv_timer_t* timer_handle() { return timer_handle_; }
|
|
171
|
+
inline ares_channel cares_channel() { return channel_; }
|
|
172
|
+
inline void set_query_last_ok(bool ok) { query_last_ok_ = ok; }
|
|
173
|
+
inline void set_is_servers_default(bool is_default) {
|
|
174
|
+
is_servers_default_ = is_default;
|
|
175
|
+
}
|
|
176
|
+
inline int active_query_count() { return active_query_count_; }
|
|
177
|
+
inline NodeAresTask::List* task_list() { return &task_list_; }
|
|
178
|
+
|
|
179
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
180
|
+
SET_MEMORY_INFO_NAME(ChannelWrap)
|
|
181
|
+
SET_SELF_SIZE(ChannelWrap)
|
|
182
|
+
|
|
183
|
+
static void AresTimeout(uv_timer_t* handle);
|
|
184
|
+
|
|
185
|
+
private:
|
|
186
|
+
uv_timer_t* timer_handle_ = nullptr;
|
|
187
|
+
ares_channel channel_ = nullptr;
|
|
188
|
+
bool query_last_ok_ = true;
|
|
189
|
+
bool is_servers_default_ = true;
|
|
190
|
+
bool library_inited_ = false;
|
|
191
|
+
int timeout_;
|
|
192
|
+
int tries_;
|
|
193
|
+
int max_timeout_;
|
|
194
|
+
int active_query_count_ = 0;
|
|
195
|
+
NodeAresTask::List task_list_;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
class GetAddrInfoReqWrap final : public ReqWrap<uv_getaddrinfo_t> {
|
|
199
|
+
public:
|
|
200
|
+
GetAddrInfoReqWrap(Environment* env,
|
|
201
|
+
v8::Local<v8::Object> req_wrap_obj,
|
|
202
|
+
uint8_t order);
|
|
203
|
+
|
|
204
|
+
SET_NO_MEMORY_INFO()
|
|
205
|
+
SET_MEMORY_INFO_NAME(GetAddrInfoReqWrap)
|
|
206
|
+
SET_SELF_SIZE(GetAddrInfoReqWrap)
|
|
207
|
+
|
|
208
|
+
uint8_t order() const { return order_; }
|
|
209
|
+
|
|
210
|
+
private:
|
|
211
|
+
const uint8_t order_;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
class GetNameInfoReqWrap final : public ReqWrap<uv_getnameinfo_t> {
|
|
215
|
+
public:
|
|
216
|
+
GetNameInfoReqWrap(Environment* env, v8::Local<v8::Object> req_wrap_obj);
|
|
217
|
+
|
|
218
|
+
SET_NO_MEMORY_INFO()
|
|
219
|
+
SET_MEMORY_INFO_NAME(GetNameInfoReqWrap)
|
|
220
|
+
SET_SELF_SIZE(GetNameInfoReqWrap)
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
struct ResponseData final {
|
|
224
|
+
int status;
|
|
225
|
+
bool is_host;
|
|
226
|
+
SafeHostEntPointer host;
|
|
227
|
+
MallocedBuffer<unsigned char> buf;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
template <typename Traits>
|
|
231
|
+
class QueryWrap final : public AsyncWrap {
|
|
232
|
+
public:
|
|
233
|
+
QueryWrap(ChannelWrap* channel, v8::Local<v8::Object> req_wrap_obj)
|
|
234
|
+
: AsyncWrap(channel->env(), req_wrap_obj, AsyncWrap::PROVIDER_QUERYWRAP),
|
|
235
|
+
channel_(channel),
|
|
236
|
+
trace_name_(Traits::name) {}
|
|
237
|
+
|
|
238
|
+
~QueryWrap() {
|
|
239
|
+
CHECK_EQ(false, persistent().IsEmpty());
|
|
240
|
+
|
|
241
|
+
// Let Callback() know that this object no longer exists.
|
|
242
|
+
if (callback_ptr_ != nullptr)
|
|
243
|
+
*callback_ptr_ = nullptr;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
int Send(const char* name) {
|
|
247
|
+
return Traits::Send(this, name);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
void AresQuery(const char* name,
|
|
251
|
+
ares_dns_class_t dnsclass,
|
|
252
|
+
ares_dns_rec_type_t type) {
|
|
253
|
+
channel_->EnsureServers();
|
|
254
|
+
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(
|
|
255
|
+
TRACING_CATEGORY_NODE2(dns, native), trace_name_, this,
|
|
256
|
+
"name", TRACE_STR_COPY(name));
|
|
257
|
+
ares_query_dnsrec(channel_->cares_channel(),
|
|
258
|
+
name,
|
|
259
|
+
dnsclass,
|
|
260
|
+
type,
|
|
261
|
+
Callback,
|
|
262
|
+
MakeCallbackPointer(),
|
|
263
|
+
nullptr);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
void ParseError(int status) {
|
|
267
|
+
CHECK_NE(status, ARES_SUCCESS);
|
|
268
|
+
v8::HandleScope handle_scope(env()->isolate());
|
|
269
|
+
v8::Context::Scope context_scope(env()->context());
|
|
270
|
+
const char* code = ToErrorCodeString(status);
|
|
271
|
+
v8::Local<v8::Value> arg = OneByteString(env()->isolate(), code);
|
|
272
|
+
TRACE_EVENT_NESTABLE_ASYNC_END1(
|
|
273
|
+
TRACING_CATEGORY_NODE2(dns, native), trace_name_, this,
|
|
274
|
+
"error", status);
|
|
275
|
+
MakeCallback(env()->oncomplete_string(), 1, &arg);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const BaseObjectPtr<ChannelWrap>& channel() const { return channel_; }
|
|
279
|
+
|
|
280
|
+
void AfterResponse() {
|
|
281
|
+
CHECK(response_data_);
|
|
282
|
+
|
|
283
|
+
int status = response_data_->status;
|
|
284
|
+
|
|
285
|
+
if (status != ARES_SUCCESS)
|
|
286
|
+
return ParseError(status);
|
|
287
|
+
|
|
288
|
+
if (!Traits::Parse(this, response_data_).To(&status)) {
|
|
289
|
+
return ParseError(ARES_ECANCELLED);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (status != ARES_SUCCESS)
|
|
293
|
+
ParseError(status);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
void* MakeCallbackPointer() {
|
|
297
|
+
CHECK_NULL(callback_ptr_);
|
|
298
|
+
callback_ptr_ = new QueryWrap<Traits>*(this);
|
|
299
|
+
return callback_ptr_;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
static QueryWrap<Traits>* FromCallbackPointer(void* arg) {
|
|
303
|
+
std::unique_ptr<QueryWrap<Traits>*> wrap_ptr {
|
|
304
|
+
static_cast<QueryWrap<Traits>**>(arg)
|
|
305
|
+
};
|
|
306
|
+
QueryWrap<Traits>* wrap = *wrap_ptr.get();
|
|
307
|
+
if (wrap == nullptr) return nullptr;
|
|
308
|
+
wrap->callback_ptr_ = nullptr;
|
|
309
|
+
return wrap;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
static void Callback(void* arg,
|
|
313
|
+
ares_status_t status,
|
|
314
|
+
size_t timeouts,
|
|
315
|
+
const ares_dns_record_t* dnsrec) {
|
|
316
|
+
QueryWrap<Traits>* wrap = FromCallbackPointer(arg);
|
|
317
|
+
if (wrap == nullptr) return;
|
|
318
|
+
|
|
319
|
+
unsigned char* buf_copy = nullptr;
|
|
320
|
+
size_t answer_len = 0;
|
|
321
|
+
if (status == ARES_SUCCESS) {
|
|
322
|
+
// No need to explicitly call ares_free_string here,
|
|
323
|
+
// as it is a wrapper around free, which is already
|
|
324
|
+
// invoked when MallocedBuffer is destructed.
|
|
325
|
+
ares_dns_write(dnsrec, &buf_copy, &answer_len);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
wrap->response_data_ = std::make_unique<ResponseData>();
|
|
329
|
+
ResponseData* data = wrap->response_data_.get();
|
|
330
|
+
data->status = status;
|
|
331
|
+
data->is_host = false;
|
|
332
|
+
data->buf = MallocedBuffer<unsigned char>(buf_copy, answer_len);
|
|
333
|
+
|
|
334
|
+
wrap->QueueResponseCallback(status);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
static void Callback(
|
|
338
|
+
void* arg,
|
|
339
|
+
int status,
|
|
340
|
+
int timeouts,
|
|
341
|
+
struct hostent* host) {
|
|
342
|
+
QueryWrap<Traits>* wrap = FromCallbackPointer(arg);
|
|
343
|
+
if (wrap == nullptr) return;
|
|
344
|
+
|
|
345
|
+
struct hostent* host_copy = nullptr;
|
|
346
|
+
if (status == ARES_SUCCESS) {
|
|
347
|
+
host_copy = node::Malloc<hostent>(1);
|
|
348
|
+
cares_wrap_hostent_cpy(host_copy, host);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
wrap->response_data_ = std::make_unique<ResponseData>();
|
|
352
|
+
ResponseData* data = wrap->response_data_.get();
|
|
353
|
+
data->status = status;
|
|
354
|
+
data->host.reset(host_copy);
|
|
355
|
+
data->is_host = true;
|
|
356
|
+
|
|
357
|
+
wrap->QueueResponseCallback(status);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
void QueueResponseCallback(int status) {
|
|
361
|
+
BaseObjectPtr<QueryWrap<Traits>> strong_ref{this};
|
|
362
|
+
env()->SetImmediate([this, strong_ref](Environment*) {
|
|
363
|
+
AfterResponse();
|
|
364
|
+
|
|
365
|
+
// Delete once strong_ref goes out of scope.
|
|
366
|
+
Detach();
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
channel_->set_query_last_ok(status != ARES_ECONNREFUSED);
|
|
370
|
+
channel_->ModifyActivityQueryCount(-1);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
void CallOnComplete(
|
|
374
|
+
v8::Local<v8::Value> answer,
|
|
375
|
+
v8::Local<v8::Value> extra = v8::Local<v8::Value>()) {
|
|
376
|
+
v8::HandleScope handle_scope(env()->isolate());
|
|
377
|
+
v8::Context::Scope context_scope(env()->context());
|
|
378
|
+
v8::Local<v8::Value> argv[] = {
|
|
379
|
+
v8::Integer::New(env()->isolate(), 0),
|
|
380
|
+
answer,
|
|
381
|
+
extra
|
|
382
|
+
};
|
|
383
|
+
const int argc = arraysize(argv) - extra.IsEmpty();
|
|
384
|
+
TRACE_EVENT_NESTABLE_ASYNC_END0(
|
|
385
|
+
TRACING_CATEGORY_NODE2(dns, native), trace_name_, this);
|
|
386
|
+
|
|
387
|
+
MakeCallback(env()->oncomplete_string(), argc, argv);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
void MemoryInfo(MemoryTracker* tracker) const override {
|
|
391
|
+
tracker->TrackField("channel", channel_);
|
|
392
|
+
if (response_data_) {
|
|
393
|
+
tracker->TrackFieldWithSize("response", response_data_->buf.size);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
SET_MEMORY_INFO_NAME(QueryWrap)
|
|
398
|
+
SET_SELF_SIZE(QueryWrap<Traits>)
|
|
399
|
+
|
|
400
|
+
private:
|
|
401
|
+
BaseObjectPtr<ChannelWrap> channel_;
|
|
402
|
+
|
|
403
|
+
std::unique_ptr<ResponseData> response_data_;
|
|
404
|
+
const char* trace_name_;
|
|
405
|
+
// Pointer to pointer to 'this' that can be reset from the destructor,
|
|
406
|
+
// in order to let Callback() know that 'this' no longer exists.
|
|
407
|
+
QueryWrap<Traits>** callback_ptr_ = nullptr;
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
#define QUERY_TYPES(V) \
|
|
411
|
+
V(Reverse, reverse, getHostByAddr) \
|
|
412
|
+
V(A, resolve4, queryA) \
|
|
413
|
+
V(Any, resolveAny, queryAny) \
|
|
414
|
+
V(Aaaa, resolve6, queryAaaa) \
|
|
415
|
+
V(Caa, resolveCaa, queryCaa) \
|
|
416
|
+
V(Cname, resolveCname, queryCname) \
|
|
417
|
+
V(Mx, resolveMx, queryMx) \
|
|
418
|
+
V(Naptr, resolveNaptr, queryNaptr) \
|
|
419
|
+
V(Ns, resolveNs, queryNs) \
|
|
420
|
+
V(Ptr, resolvePtr, queryPtr) \
|
|
421
|
+
V(Srv, resolveSrv, querySrv) \
|
|
422
|
+
V(Soa, resolveSoa, querySoa) \
|
|
423
|
+
V(Tlsa, resolveTlsa, queryTlsa) \
|
|
424
|
+
V(Txt, resolveTxt, queryTxt)
|
|
425
|
+
|
|
426
|
+
// All query type handlers share the same basic structure, so we can simplify
|
|
427
|
+
// the code a bit by using a macro to define that structure.
|
|
428
|
+
#define TYPE_TRAITS(Name, label) \
|
|
429
|
+
struct Name##Traits final { \
|
|
430
|
+
static constexpr const char* name = #label; \
|
|
431
|
+
static int Send(QueryWrap<Name##Traits>* wrap, const char* name); \
|
|
432
|
+
static v8::Maybe<int> Parse( \
|
|
433
|
+
QueryWrap<Name##Traits>* wrap, \
|
|
434
|
+
const std::unique_ptr<ResponseData>& response); \
|
|
435
|
+
}; \
|
|
436
|
+
using Query##Name##Wrap = QueryWrap<Name##Traits>;
|
|
437
|
+
|
|
438
|
+
#define V(NAME, LABEL, _) TYPE_TRAITS(NAME, LABEL)
|
|
439
|
+
QUERY_TYPES(V)
|
|
440
|
+
#undef V
|
|
441
|
+
#undef TYPE_TRAITS
|
|
442
|
+
} // namespace cares_wrap
|
|
443
|
+
} // namespace node
|
|
444
|
+
|
|
445
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
446
|
+
|
|
447
|
+
#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 "2.2.0"
|
|
6
|
+
#endif // SRC_CJS_MODULE_LEXER_VERSION_H_
|
|
@@ -0,0 +1,36 @@
|
|
|
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 "cleanup_queue.h"
|
|
7
|
+
#include "util.h"
|
|
8
|
+
|
|
9
|
+
namespace node {
|
|
10
|
+
|
|
11
|
+
inline size_t CleanupQueue::SelfSize() const {
|
|
12
|
+
return sizeof(CleanupQueue) +
|
|
13
|
+
cleanup_hooks_.size() * sizeof(CleanupHookCallback);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
bool CleanupQueue::empty() const {
|
|
17
|
+
return cleanup_hooks_.empty();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void CleanupQueue::Add(Callback cb, void* arg) {
|
|
21
|
+
auto insertion_info =
|
|
22
|
+
cleanup_hooks_.emplace(cb, arg, cleanup_hook_counter_++);
|
|
23
|
+
// Make sure there was no existing element with these values.
|
|
24
|
+
CHECK_EQ(insertion_info.second, true);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void CleanupQueue::Remove(Callback cb, void* arg) {
|
|
28
|
+
CleanupHookCallback search{cb, arg, 0};
|
|
29
|
+
cleanup_hooks_.erase(search);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
} // namespace node
|
|
33
|
+
|
|
34
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
35
|
+
|
|
36
|
+
#endif // SRC_CLEANUP_QUEUE_INL_H_
|
|
@@ -0,0 +1,79 @@
|
|
|
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 CleanupQueue : public MemoryRetainer {
|
|
16
|
+
public:
|
|
17
|
+
typedef void (*Callback)(void*);
|
|
18
|
+
|
|
19
|
+
CleanupQueue() = default;
|
|
20
|
+
|
|
21
|
+
// Not copyable.
|
|
22
|
+
CleanupQueue(const CleanupQueue&) = delete;
|
|
23
|
+
|
|
24
|
+
SET_MEMORY_INFO_NAME(CleanupQueue)
|
|
25
|
+
SET_NO_MEMORY_INFO()
|
|
26
|
+
inline size_t SelfSize() const override;
|
|
27
|
+
|
|
28
|
+
inline bool empty() const;
|
|
29
|
+
|
|
30
|
+
inline void Add(Callback cb, void* arg);
|
|
31
|
+
inline void Remove(Callback cb, void* arg);
|
|
32
|
+
void Drain();
|
|
33
|
+
|
|
34
|
+
private:
|
|
35
|
+
class CleanupHookCallback {
|
|
36
|
+
public:
|
|
37
|
+
CleanupHookCallback(Callback fn,
|
|
38
|
+
void* arg,
|
|
39
|
+
uint64_t insertion_order_counter)
|
|
40
|
+
: fn_(fn),
|
|
41
|
+
arg_(arg),
|
|
42
|
+
insertion_order_counter_(insertion_order_counter) {}
|
|
43
|
+
|
|
44
|
+
// Only hashes `arg_`, since that is usually enough to identify the hook.
|
|
45
|
+
struct Hash {
|
|
46
|
+
size_t operator()(const CleanupHookCallback& cb) const;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Compares by `fn_` and `arg_` being equal.
|
|
50
|
+
struct Equal {
|
|
51
|
+
bool operator()(const CleanupHookCallback& a,
|
|
52
|
+
const CleanupHookCallback& b) const;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
private:
|
|
56
|
+
friend class CleanupQueue;
|
|
57
|
+
Callback fn_;
|
|
58
|
+
void* arg_;
|
|
59
|
+
|
|
60
|
+
// We keep track of the insertion order for these objects, so that we can
|
|
61
|
+
// call the callbacks in reverse order when we are cleaning up.
|
|
62
|
+
uint64_t insertion_order_counter_;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
std::vector<CleanupHookCallback> GetOrdered() const;
|
|
66
|
+
|
|
67
|
+
// Use an unordered_set, so that we have efficient insertion and removal.
|
|
68
|
+
std::unordered_set<CleanupHookCallback,
|
|
69
|
+
CleanupHookCallback::Hash,
|
|
70
|
+
CleanupHookCallback::Equal>
|
|
71
|
+
cleanup_hooks_;
|
|
72
|
+
uint64_t cleanup_hook_counter_ = 0;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace node
|
|
76
|
+
|
|
77
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
78
|
+
|
|
79
|
+
#endif // SRC_CLEANUP_QUEUE_H_
|