Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspector: Put connect and disconnect events into message queue #7271

Closed
wants to merge 1 commit into from
Closed

inspector: Put connect and disconnect events into message queue #7271

wants to merge 1 commit into from

Conversation

eugeneo
Copy link
Contributor

@eugeneo eugeneo commented Jun 11, 2016

Checklist
  • make -j4 test (UNIX) or vcbuild test nosign (Windows) passes
  • the commit message follows commit guidelines
Affected core subsystem(s)

inspector

Description of change

Putting connect and disconnect events into the message queue removes some unlikely race conditions. It also allows reusing the V8 interrupt when frontend connects to Node.js running an infinite loop.

CC: @ofrobots

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jun 11, 2016
@eugeneo
Copy link
Contributor Author

eugeneo commented Jun 11, 2016

Please note that this PR needs fixes uploaded in #7268 - hence the 2 commits.

@mscdex mscdex added inspector Issues and PRs related to the V8 inspector protocol c++ Issues and PRs that require attention from people who are familiar with C++. and removed c++ Issues and PRs that require attention from people who are familiar with C++. labels Jun 11, 2016
@ofrobots
Copy link
Contributor

@eugeneo Now that #7268 has landed, can you rebase this on top of master?

@eugeneo
Copy link
Contributor Author

eugeneo commented Jun 17, 2016

@ofrobots Done. Thanks!

@bnoordhuis
Copy link
Member

@eugeneo Can you rebase? Thanks.

@eugeneo
Copy link
Contributor Author

eugeneo commented Jun 22, 2016

I rebased the change. Thanks!

@@ -170,24 +173,28 @@ class AgentImpl {
void WaitForDisconnect();

private:
using MessageQueue =
std::vector<std::pair<int, const blink::protocol::String16>>;
Copy link
Member

@bnoordhuis bnoordhuis Jun 23, 2016

Choose a reason for hiding this comment

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

Just a suggestion but you could add a using blink::protocol::String16; at the top.

EDIT: I guess it already exists somewhere? I see that line 197 uses a non-qualified name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. String16STD.h already imports it into the default namespace - so I'll be using it.

@eugeneo
Copy link
Contributor Author

eugeneo commented Jun 29, 2016

@bnoordhuis Please take another look. I addressed the comments and rebased the change. Thanks!

v8::Isolate* isolate = parent_env_->isolate();
platform_->CallOnForegroundThread(isolate,
new DispatchOnInspectorBackendTask(this));
isolate ->RequestInterrupt(InterruptCallback, this);
Copy link
Member

Choose a reason for hiding this comment

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

extra space?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, artifact of line joining. Fixed/reuploaded. Thanks!

@eugeneo
Copy link
Contributor Author

eugeneo commented Jun 30, 2016

@bnoordhuis Thanks for the review. I updated the code.

@bnoordhuis
Copy link
Member

LGTM

@ofrobots
Copy link
Contributor

ofrobots commented Jul 1, 2016

Current implementation tracks connected/disconnected status separately
which potentially introduces race condition.
This change introduces notion of session IDs and also posts
connect/disconnect events into the same queue as the messages. This way
Node knows what session given response belongs to and can discard
messages if the frontend for that session had disconnected.

This also fixes an issue when frontend was unable to attach to V8
instance that was running infinite loop.
@eugeneo
Copy link
Contributor Author

eugeneo commented Jul 1, 2016

@ofrobots I updated the CL with a fix for the libc++ (Mac/BSD build issue). The only change was that MessageQueue vector now stores String16 and not cons String16.

@ofrobots
Copy link
Contributor

ofrobots commented Jul 1, 2016

New CI: https://ci.nodejs.org/job/node-test-pull-request/3156/. Looks green.

@ofrobots
Copy link
Contributor

Apologies for the delay. Since it has been ~2 weeks since the last CI, I reran a new one here: https://ci.nodejs.org/job/node-test-pull-request/3299/.

@ofrobots
Copy link
Contributor

Looks green modulo arm-fanned jobs which seems to be a jenkins slave issue.

ofrobots pushed a commit that referenced this pull request Jul 15, 2016
Current implementation tracks connected/disconnected status separately
which potentially introduces race condition.
This change introduces notion of session IDs and also posts
connect/disconnect events into the same queue as the messages. This way
Node knows what session given response belongs to and can discard
messages if the frontend for that session had disconnected.

This also fixes an issue when frontend was unable to attach to V8
instance that was running infinite loop.

PR-URL: #7271
Reviewed-By: bnoordhuis - Ben Noordhuis <[email protected]>
@ofrobots
Copy link
Contributor

Landed as 4220c24.

@ofrobots ofrobots closed this Jul 15, 2016
evanlucas pushed a commit that referenced this pull request Jul 18, 2016
Current implementation tracks connected/disconnected status separately
which potentially introduces race condition.
This change introduces notion of session IDs and also posts
connect/disconnect events into the same queue as the messages. This way
Node knows what session given response belongs to and can discard
messages if the frontend for that session had disconnected.

This also fixes an issue when frontend was unable to attach to V8
instance that was running infinite loop.

PR-URL: #7271
Reviewed-By: bnoordhuis - Ben Noordhuis <[email protected]>
evanlucas pushed a commit that referenced this pull request Jul 20, 2016
Current implementation tracks connected/disconnected status separately
which potentially introduces race condition.
This change introduces notion of session IDs and also posts
connect/disconnect events into the same queue as the messages. This way
Node knows what session given response belongs to and can discard
messages if the frontend for that session had disconnected.

This also fixes an issue when frontend was unable to attach to V8
instance that was running infinite loop.

PR-URL: #7271
Reviewed-By: bnoordhuis - Ben Noordhuis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants