mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
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:
1 parent
bbdf2684d5
commit
efd6f68dce
2 files changed
+4
-3
No files matched your search
+1
-1
@@ -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), []);
|
||||
}));
|
||||
|
||||
Reference in new issue
Block a user