summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Madsen <amwebdk@gmail.com>2012-02-01 17:23:25 +0100
committerisaacs <i@izs.me>2012-02-06 14:54:11 -0800
commit1595a6e885eebd5a9d854bd462ab1b80521ff754 (patch)
treed37bdb8b3ddb5e8a064050a9cf7eaef9bdbac4f4
parenta20872045a1e153f6687d37f4d824739e3a60b27 (diff)
downloadnode-new-1595a6e885eebd5a9d854bd462ab1b80521ff754.tar.gz
cluster: use process.disconnect method
After adding a .disconect method and connected flag in child_process we should no longer use the process._channel object.
-rw-r--r--lib/cluster.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/cluster.js b/lib/cluster.js
index f08b15d0bb..205df81466 100644
--- a/lib/cluster.js
+++ b/lib/cluster.js
@@ -381,20 +381,18 @@ Worker.prototype.destroy = function() {
this.suicide = true;
if (cluster.isMaster) {
- // Stop channel
+ // Disconnect IPC channel
// this way the worker won't need to propagate suicide state to master
closeWorkerChannel(this, function() {
- // Then kill worker
self.process.kill();
});
} else {
// Channel is open
- if (this.process._channel !== null) {
+ if (this.process.connected) {
// Inform master that is is suicide and then kill
sendInternalMessage(this, {cmd: 'suicide'}, function() {
- // Kill worker
process.exit(0);
});
@@ -404,7 +402,7 @@ Worker.prototype.destroy = function() {
// from the master is resicved. Also we can't do a timeout and then
// just kill, since we don't know if the quickDestroy function was called.
setInterval(function() {
- if (self.process._channel === null) {
+ if (!self.process.connected) {
process.exit(0);
}
}, 200);
@@ -430,6 +428,7 @@ cluster.fork = function(env) {
// However the workers may not die instantly
function quickDestroyCluster() {
eachWorker(function(worker) {
+ worker.process.disconnect();
worker.process.kill();
});
}