cluster: dont rely on this in fork

PR-URL: https://github.com/nodejs/node/pull/5216
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
This commit is contained in:
Igor Klopov authored and Rod Vagg committed 2016-02-18 14:02:56 +11:00
1 parent bbdf2684d5
commit efd6f68dce
2 files changed
+4 -3

No files matched your search

+1 -1
View File
@@ -342,7 +342,7 @@ function masterInit() {
});
worker.on('message', (message, handle) =>
this.emit('message', message, handle)
cluster.emit('message', message, handle)
);
worker.process.once('exit', function(exitCode, signalCode) {
@@ -2,10 +2,11 @@
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
var fork = cluster.fork;
if (cluster.isMaster) {
cluster.fork();
cluster.fork();
fork(); // it is intentionally called `fork` instead of
fork(); // `cluster.fork` to test that `this` is not used
cluster.disconnect(common.mustCall(function() {
assert.deepEqual(Object.keys(cluster.workers), []);
}));