Skip to content

inspector: split HTTP/WS server from the inspector - #9630

Merged
eugeneo merged 0 commit into
nodejs:masterfrom
eugeneo:socket_server
Dec 6, 2016
Merged

inspector: split HTTP/WS server from the inspector#9630
eugeneo merged 0 commit into
nodejs:masterfrom
eugeneo:socket_server

Conversation

@eugeneo

Copy link
Copy Markdown
Contributor
Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

inspector: HTTP server code was reworked and moved to a new file. No impact if the inspector is not started.

Description of change

Both our team experiments and some embedder request indicate a potential
in implementing alternative transport for inspector - e.g. IPC pipes or
custom embedder APIs. This change moves all HTTP specific code into a
separate class and is a first attempt at defining a boundary between the
inspector agent and transport. This API will be refined as new
transports are implemented.
Note that even without considering alternative transports, this change
enables better testing of the HTTP server (Valgrind it possible to identify
and fix some existing memory leaks).

CC: @ofrobots

@nodejs-github-botnodejs-github-bot added build Issues and PRs related to build files or the CI. c++ Issues and PRs that require attention from people who are familiar with C++. labels Nov 16, 2016
@bnoordhuis

Copy link
Copy Markdown
Member

Related test failures on the OS X buildbot: https://ci.nodejs.org/job/node-test-commit-osx/6038/nodes=osx1010/console - some inspector cctests are failing.

@eugeneo

Copy link
Copy Markdown
ContributorAuthor

I fixed the issues CI identified. New CI run (https://ci.nodejs.org/job/node-test-pull-request/4863/) seems to pass on all platforms, except ARM. Failures there seem to have to do with infrastructure failures unrelated to this PR.

Comment threadnode.gyp Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment threadsrc/inspector_agent.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alignment is off here.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment threadsrc/inspector_agent.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning const values (not references) is kind of odd. Doesn't g++ complain about that?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It did not complain (neither did clang/Mac), I removed the const none the less.

Comment threadsrc/inspector_agent.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? An explaining comment would be good.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary "command" to stop accepting new connections. In next pull request there will be a better API with meaningful requests as opposed to magical strings...

Comment threadsrc/inspector_agent.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't seem to reset delegate_ to nullptr anywhere.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment threadsrc/inspector_agent.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto for server_, it looks like.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment threadsrc/inspector_agent.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary whitespace change.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment threadsrc/inspector_agent.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods don't seem to be used or defined anywhere.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, at some points was considering a slightly different API.

Comment threadsrc/inspector_socket_server.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you line up the arguments?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment threadsrc/inspector_socket_server.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be unused.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this ultimately remained in inspector_agent.cc...

@eugeneo

eugeneo commented Nov 17, 2016

Copy link
Copy Markdown
ContributorAuthor

@bnoordhuis Thank you for reviewing it. I addressed your comments (and also did another pass through function names and such). Please take another look.

@eugeneo

Copy link
Copy Markdown
ContributorAuthor

I am looking to rework this quite a bit, to define an easier to use API. Please do not review it for now.

@eugeneo

Copy link
Copy Markdown
ContributorAuthor

PR had been reworked, please review. I replaced the Session object with an integer session_id, it simplified the API.

Comment threadsrc/inspector_socket_server.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all critical but doesn't it make more sense to use a std::set?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment threadsrc/inspector_socket_server.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused, it seems?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, thanks.

Comment threadsrc/inspector_socket_server.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target_ids

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share this code with test_inspector_socket.cc?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That test is due for a more comprehensive cleanup so I will do it then (this will require adding new files, etc).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny alignment.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is off.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is off.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Teeny tiny nit: we usually put a space before the <.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the long lines in this file?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@eugeneo

Copy link
Copy Markdown
ContributorAuthor

@bnoordhuis Thank you for the review. I uploaded updated commit, please take another look.

@eugeneo

Copy link
Copy Markdown
ContributorAuthor

@bnoordhuis I've updated the change, fixing the cpplint comment on the new test.

@eugeneo

Copy link
Copy Markdown
ContributorAuthor

I see a FreeBSD test failure that does not seem to be connected to this change.

@bnoordhuisbnoordhuis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a suggestion.

Comment threadsrc/inspector_socket_server.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: s/sserver/socket_server/ - the difference between server and sserver is very subtle.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the linter complaining about a using directive outside a namespace?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the directives inside the namespace. Linter was fine - don't know if it is because of its settings.

@eugeneo

Copy link
Copy Markdown
ContributorAuthor

Looks like https://ci.nodejs.org/job/node-test-pull-request/5271/ is all green but some glitch is preventing thew results to be reported back to GitHuib.

@eugeneoeugeneo closed this Dec 6, 2016
@eugeneo
eugeneo merged commit 42da740 into nodejs:masterDec 6, 2016
@eugeneo
eugeneo deleted the socket_server branch December 6, 2016 22:50
@eugeneo

Copy link
Copy Markdown
ContributorAuthor

Landed as 42da740

@MylesBorins

Copy link
Copy Markdown
Contributor

@Fishrock123 this is another example of something that likely should not have gotten the dont-land label

@MylesBorins

Copy link
Copy Markdown
Contributor

@eugeneo should this be backported to v6 or is this an example of something that requires the latest version of inspector api?

@eugeneo

Copy link
Copy Markdown
ContributorAuthor

This is a refactoring and does not require a new V8 inspector. I am not sure if it is needed for v6 (I'm not familiar with the policies) as main goal is to enable development of new features.

@evanlucasevanlucas mentioned this pull request Jan 3, 2017
evanlucas pushed a commit that referenced this pull request Jan 3, 2017
Both our team experiments and some embedder request indicate a potential
in implementing alternative transport for inspector - e.g. IPC pipes or
custom embedder APIs. This change moves all HTTP specific code into a
separate class and is a first attempt at defining a boundary between the
inspector agent and transport. This API will be refined as new
transports are implemented.
Note that even without considering alternative transports, this change
enables better testing of the HTTP server (Valgrind made it possible to
identify and fix some existing memory leaks).
PR-URL: #9630
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
evanlucas pushed a commit that referenced this pull request Jan 4, 2017
Both our team experiments and some embedder request indicate a potential
in implementing alternative transport for inspector - e.g. IPC pipes or
custom embedder APIs. This change moves all HTTP specific code into a
separate class and is a first attempt at defining a boundary between the
inspector agent and transport. This API will be refined as new
transports are implemented.
Note that even without considering alternative transports, this change
enables better testing of the HTTP server (Valgrind made it possible to
identify and fix some existing memory leaks).
PR-URL: #9630
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@gibfahn

Copy link
Copy Markdown
Member

If this is backported it should be backported with #10657

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

buildIssues and PRs related to build files or the CI.c++Issues and PRs that require attention from people who are familiar with C++.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@eugeneo@bnoordhuis@MylesBorins@gibfahn@jasnell@nodejs-github-bot