diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-12-01 20:30:30 +0300 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-12-09 01:26:53 +0300 |
commit | 61a89630ee5664b1f909b310a016b522a6285521 (patch) | |
tree | 621fbd9bfd9c25a43c3ff9ae60251e5bfa2d366c /src/node_config.cc | |
parent | 22564b99cb9dff471f40c1ad0245d99b9224a207 (diff) |
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 <anna@addaleax.net>
Diffstat (limited to 'src/node_config.cc')
-rw-r--r-- | src/node_config.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/node_config.cc b/src/node_config.cc index c2bf3349c46..27ec44b8d30 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<Object> target, READONLY_STRING_PROPERTY(target, "warningFile", warning_file); } - std::shared_ptr<DebugOptions> debug_options = env->options()->debug_options; Local<Object> 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 |