summaryrefslogtreecommitdiff
path: root/src/env.h
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-12-02 01:30:30 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-12-09 06:26:53 +0800
commit61a89630ee5664b1f909b310a016b522a6285521 (patch)
tree621fbd9bfd9c25a43c3ff9ae60251e5bfa2d366c /src/env.h
parent22564b99cb9dff471f40c1ad0245d99b9224a207 (diff)
downloadandroid-node-v8-61a89630ee5664b1f909b310a016b522a6285521.tar.gz
android-node-v8-61a89630ee5664b1f909b310a016b522a6285521.tar.bz2
android-node-v8-61a89630ee5664b1f909b310a016b522a6285521.zip
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/env.h')
-rw-r--r--src/env.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/env.h b/src/env.h
index 64593a0025..ec0368e040 100644
--- a/src/env.h
+++ b/src/env.h
@@ -911,6 +911,7 @@ class Environment {
void* data);
inline std::shared_ptr<EnvironmentOptions> options();
+ inline std::shared_ptr<HostPort> inspector_host_port();
private:
inline void CreateImmediate(native_immediate_callback cb,
@@ -942,6 +943,14 @@ class Environment {
std::vector<double> destroy_async_id_list_;
std::shared_ptr<EnvironmentOptions> options_;
+ // options_ contains debug options parsed from CLI arguments,
+ // while inspector_host_port_ stores the actual inspector host
+ // and port being used. For example the port is -1 by default
+ // and can be specified as 0 (meaning any port allocated when the
+ // server starts listening), but when the inspector server starts
+ // the inspector_host_port_->port() will be the actual port being
+ // used.
+ std::shared_ptr<HostPort> inspector_host_port_;
uint32_t module_id_counter_ = 0;
uint32_t script_id_counter_ = 0;