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/inspector_js_api.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/inspector_js_api.cc')
-rw-r--r-- | src/inspector_js_api.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index 52f14639a43..1cb51b51ec0 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -243,12 +243,12 @@ void Open(const FunctionCallbackInfo<Value>& args) { if (args.Length() > 0 && args[0]->IsUint32()) { uint32_t port = args[0].As<Uint32>()->Value(); - agent->options()->host_port.port = port; + agent->host_port()->set_port(static_cast<int>(port)); } if (args.Length() > 1 && args[1]->IsString()) { Utf8Value host(env->isolate(), args[1].As<String>()); - agent->options()->host_port.host_name = *host; + agent->host_port()->set_host(*host); } if (args.Length() > 2 && args[2]->IsBoolean()) { |