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

node: set process._eventsCount to 0 on startup #5208

Merged
merged 1 commit into from
Feb 15, 2016

Conversation

evanlucas
Copy link
Contributor

process is an EventEmitter. There are operations that increment and
decrement the _eventsCount property of an EventEmitter.
process._eventsCount would previously get set to NaN. This change makes
process._eventsCount be calculated as expected.

@vkurchatkin
Copy link
Contributor

Can we just call constructor from JS side?

@mscdex
Copy link
Contributor

mscdex commented Feb 13, 2016

LGTM

@mscdex mscdex added events Issues and PRs related to the events subsystem / EventEmitter. process Issues and PRs related to the process subsystem. labels Feb 13, 2016
@evanlucas
Copy link
Contributor Author

@vkurchatkin we certainly could. I played with it and didn't see any difference in performance. Any particular reason you would prefer that?

@jasnell
Copy link
Member

jasnell commented Feb 13, 2016

LGTM

@@ -18,3 +18,6 @@ process.on('SIGPIPE', common.mustCall((data) => {
process.emit('normal', 'normalData');
process.emit(sym, 'symbolData');
process.emit('SIGPIPE', 'signalData');

assert.strictEqual(typeof process._eventsCount, 'number');
assert.strictEqual(isNaN(process._eventsCount), false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Both these tests can be combined with Number.isNaN

@bnoordhuis
Copy link
Member

Can we just call constructor from JS side?

That would be my suggestion as well.

Aside, if events_count_string is used only once, don't add it to the persistent string table, just create it at the use site.

@evanlucas evanlucas force-pushed the proceventscount branch 2 times, most recently from 867fbf8 to 3589630 Compare February 14, 2016 22:10
@evanlucas
Copy link
Contributor Author

Ok, changed to set on the JS side. Also fixed up the test per @thefourtheye.

CI: https://ci.nodejs.org/job/node-test-pull-request/1657/

Thanks!

@@ -18,3 +18,5 @@ process.on('SIGPIPE', common.mustCall((data) => {
process.emit('normal', 'normalData');
process.emit(sym, 'symbolData');
process.emit('SIGPIPE', 'signalData');

assert.strictEqual(Number.isNaN(process._eventsCount), false);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't you use global isNaN() here? Number.isNaN('boom') would pass because it returns false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah good catch. fixing

@evanlucas
Copy link
Contributor Author

Fixed Ben's comment.

CI: https://ci.nodejs.org/job/node-test-pull-request/1662/

@bnoordhuis
Copy link
Member

LGTM

process is an EventEmitter. There are operations that increment and
decrement the _eventsCount property of an EventEmitter.
process._eventsCount would previously get set to NaN. This change makes
process._eventsCount be calculated as expected.

PR-URL: nodejs#5208
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@evanlucas evanlucas closed this Feb 15, 2016
@evanlucas evanlucas deleted the proceventscount branch February 15, 2016 15:35
@evanlucas evanlucas merged commit 31ebda2 into nodejs:master Feb 15, 2016
@evanlucas
Copy link
Contributor Author

Landed in 31ebda2. Thanks!

rvagg pushed a commit that referenced this pull request Feb 15, 2016
process is an EventEmitter. There are operations that increment and
decrement the _eventsCount property of an EventEmitter.
process._eventsCount would previously get set to NaN. This change makes
process._eventsCount be calculated as expected.

PR-URL: #5208
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
stefanmb pushed a commit to stefanmb/node that referenced this pull request Feb 23, 2016
process is an EventEmitter. There are operations that increment and
decrement the _eventsCount property of an EventEmitter.
process._eventsCount would previously get set to NaN. This change makes
process._eventsCount be calculated as expected.

PR-URL: nodejs#5208
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Mar 1, 2016
process is an EventEmitter. There are operations that increment and
decrement the _eventsCount property of an EventEmitter.
process._eventsCount would previously get set to NaN. This change makes
process._eventsCount be calculated as expected.

PR-URL: #5208
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Mar 1, 2016
process is an EventEmitter. There are operations that increment and
decrement the _eventsCount property of an EventEmitter.
process._eventsCount would previously get set to NaN. This change makes
process._eventsCount be calculated as expected.

PR-URL: #5208
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Mar 2, 2016
process is an EventEmitter. There are operations that increment and
decrement the _eventsCount property of an EventEmitter.
process._eventsCount would previously get set to NaN. This change makes
process._eventsCount be calculated as expected.

PR-URL: #5208
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
events Issues and PRs related to the events subsystem / EventEmitter. process Issues and PRs related to the process subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants