aboutsummaryrefslogtreecommitdiff
path: root/src/inspector_io.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/inspector_io.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/inspector_io.h')
-rw-r--r--src/inspector_io.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/inspector_io.h b/src/inspector_io.h
index 21df54e031..bc09afdd3d 100644
--- a/src/inspector_io.h
+++ b/src/inspector_io.h
@@ -46,21 +46,22 @@ class InspectorIo {
// bool Start();
// Returns empty pointer if thread was not started
static std::unique_ptr<InspectorIo> Start(
- std::shared_ptr<MainThreadHandle> main_thread, const std::string& path,
- std::shared_ptr<DebugOptions> options);
+ std::shared_ptr<MainThreadHandle> main_thread,
+ const std::string& path,
+ std::shared_ptr<HostPort> host_port);
// Will block till the transport thread shuts down
~InspectorIo();
void StopAcceptingNewConnections();
- const std::string& host() const { return options_->host(); }
- int port() const { return port_; }
+ const std::string& host() const { return host_port_->host(); }
+ int port() const { return host_port_->port(); }
std::vector<std::string> GetTargetIds() const;
private:
InspectorIo(std::shared_ptr<MainThreadHandle> handle,
const std::string& path,
- std::shared_ptr<DebugOptions> options);
+ std::shared_ptr<HostPort> host_port);
// Wrapper for agent->ThreadMain()
static void ThreadMain(void* agent);
@@ -74,7 +75,7 @@ class InspectorIo {
// Used to post on a frontend interface thread, lives while the server is
// running
std::shared_ptr<RequestQueue> request_queue_;
- std::shared_ptr<DebugOptions> options_;
+ std::shared_ptr<HostPort> host_port_;
// The IO thread runs its own uv_loop to implement the TCP server off
// the main thread.
@@ -84,7 +85,6 @@ class InspectorIo {
Mutex thread_start_lock_;
ConditionVariable thread_start_condition_;
std::string script_name_;
- int port_ = -1;
// May be accessed from any thread
const std::string id_;
};