From 61a89630ee5664b1f909b310a016b522a6285521 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sun, 2 Dec 2018 01:30:30 +0800 Subject: inspector: split the HostPort being used and the one parsed from CLI Instead of using a shared pointer of the entire debug option set, pass the parsed debug option to inspector classes by value because they are set once the CLI argument parsing is done. Add another shared pointer to HostPort being used by the inspector server, which is copied from the one in the debug options initially. The port of the shared HostPort is 9229 by default and can be specified as 0 initially but will be set to the actual port of the server once it starts listening. This makes the shared state clearer and makes it possible to use `require('internal/options')` in JS land to query the CLI options instead of using `process._breakFirstLine` and other underscored properties of `process` since we are now certain that these values should not be altered once the parsing is done and can be passed around in copies without locks. PR-URL: https://github.com/nodejs/node/pull/24772 Reviewed-By: Anna Henningsen --- src/node_config.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/node_config.cc') diff --git a/src/node_config.cc b/src/node_config.cc index c2bf3349c4..27ec44b8d3 100644 --- a/src/node_config.cc +++ b/src/node_config.cc @@ -1,5 +1,6 @@ #include "node.h" #include "node_i18n.h" +#include "node_options-inl.h" #include "env-inl.h" #include "util-inl.h" @@ -94,20 +95,18 @@ static void Initialize(Local target, READONLY_STRING_PROPERTY(target, "warningFile", warning_file); } - std::shared_ptr debug_options = env->options()->debug_options; Local debug_options_obj = Object::New(isolate); READONLY_PROPERTY(target, "debugOptions", debug_options_obj); - READONLY_STRING_PROPERTY(debug_options_obj, "host", - debug_options->host()); - - READONLY_PROPERTY(debug_options_obj, - "port", - Integer::New(isolate, debug_options->port())); - + const DebugOptions& debug_options = env->options()->debug_options(); READONLY_PROPERTY(debug_options_obj, "inspectorEnabled", - Boolean::New(isolate, debug_options->inspector_enabled)); + Boolean::New(isolate, debug_options.inspector_enabled)); + READONLY_STRING_PROPERTY( + debug_options_obj, "host", debug_options.host_port.host()); + READONLY_PROPERTY(debug_options_obj, + "port", + Integer::New(isolate, debug_options.host_port.port())); } // InitConfig } // namespace node -- cgit v1.2.3