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

cluster: reset handle index on close #6981

Merged
merged 1 commit into from
May 27, 2016
Merged

Conversation

santigimeno
Copy link
Member

Checklist
  • tests and code linting passes
  • a test and/or benchmark is included
  • documentation is changed or added
  • the commit message follows commit guidelines
Affected core subsystem(s)
Description of change

It allows reopening a server after it has been closed.

Fixes: #6693.

/cc @cjihrig @bnoordhuis

@nodejs-github-bot nodejs-github-bot added the cluster Issues and PRs related to the cluster subsystem. label May 25, 2016
@santigimeno
Copy link
Member Author

@@ -636,6 +638,8 @@ function workerInit() {
if (key === undefined) return;
send({ act: 'close', key: key });
delete handles[key];
const indexesKey = key.substring(0, key.lastIndexOf(':'));
indexes[indexesKey] = undefined;
Copy link
Member

Choose a reason for hiding this comment

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

This looks too hacky. I'd rename the const key = ... at the top of cluster._getServer() to const indexesKey and use that here.

Also, this would be a place where the delete operator is warranted, otherwise indexes can grow unchecked.

Copy link
Member Author

Choose a reason for hiding this comment

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

This looks too hacky. I'd rename the const key = ... at the top of cluster._getServer() to const indexesKey and use that here.

Maybe I'm missing something, but how would I do that? They're in different contexts. I can pass it to the shared and rr functions as an argument though.

Also, this would be a place where the delete operator is warranted, otherwise indexes can grow unchecked.

You're right. Will fix.

Thanks!

@santigimeno
Copy link
Member Author

PR updated with @bnoordhuis suggestions. Thanks!

@santigimeno
Copy link
Member Author

else
rr(reply, cb); // Round-robin.
rr(reply, key, cb); // Round-robin.
Copy link
Member

Choose a reason for hiding this comment

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

I'd rename key to indexesKey for better greppability.

@santigimeno
Copy link
Member Author

Updated. Thanks!

@santigimeno
Copy link
Member Author

@bnoordhuis
Copy link
Member

bnoordhuis commented May 26, 2016

LGTM. armv7-ubuntu1404 has a lot of failures but they are probably caused by something else. I suspect a debugger test.

const worker1 = cluster.fork();
worker1.on('listening', common.mustCall(() => {
const worker2 = cluster.fork();
worker2.on('exit', (code) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be a common.mustCall()? It might be good to test worker1's exit code too.

@cjihrig
Copy link
Contributor

cjihrig commented May 26, 2016

LGTM with one comment.

@santigimeno
Copy link
Member Author

PR update per @cjihrig comments. Thanks

@santigimeno
Copy link
Member Author

@ronkorving
Copy link
Contributor

LGTM

1 similar comment
@jasnell
Copy link
Member

jasnell commented May 27, 2016

LGTM

@santigimeno
Copy link
Member Author

@santigimeno
Copy link
Member Author

CI looks good except for the current flakes. Landing.

It allows reopening a server after it has been closed.

Fixes: nodejs#6693
PR-URL: nodejs#6981
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ron Korving <ron@ronkorving.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
@santigimeno
Copy link
Member Author

Landed in 0c29436. Thanks!

Fishrock123 pushed a commit to Fishrock123/node that referenced this pull request May 30, 2016
It allows reopening a server after it has been closed.

Fixes: nodejs#6693
PR-URL: nodejs#6981
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ron Korving <ron@ronkorving.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
rvagg pushed a commit that referenced this pull request Jun 2, 2016
It allows reopening a server after it has been closed.

Fixes: #6693
PR-URL: #6981
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ron Korving <ron@ronkorving.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins
Copy link
Contributor

@santigimeno / @bnoordhuis lts?

@santigimeno
Copy link
Member Author

@thealphanerd, yes.

MylesBorins pushed a commit that referenced this pull request Jul 12, 2016
It allows reopening a server after it has been closed.

Fixes: #6693
PR-URL: #6981
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ron Korving <ron@ronkorving.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jul 12, 2016
It allows reopening a server after it has been closed.

Fixes: #6693
PR-URL: #6981
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ron Korving <ron@ronkorving.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Jul 12, 2016
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
It allows reopening a server after it has been closed.

Fixes: #6693
PR-URL: #6981
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ron Korving <ron@ronkorving.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
It allows reopening a server after it has been closed.

Fixes: #6693
PR-URL: #6981
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ron Korving <ron@ronkorving.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cluster Issues and PRs related to the cluster subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cluster workers not sharing ports after reopening a listener
7 participants