summaryrefslogtreecommitdiff
path: root/lib/cluster.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2016-05-23 10:55:48 -0400
committercjihrig <cjihrig@gmail.com>2016-05-24 12:20:57 -0400
commitaadfe6c24900688fa7dfb9760451cdfa5f9d1fcc (patch)
treef51f79df739b00a76c6ecf3857c82c2514bb39b0 /lib/cluster.js
parentdd21bd9f01de7044ed50e4b03b7dd349dbc7ee4e (diff)
downloadandroid-node-v8-aadfe6c24900688fa7dfb9760451cdfa5f9d1fcc.tar.gz
android-node-v8-aadfe6c24900688fa7dfb9760451cdfa5f9d1fcc.tar.bz2
android-node-v8-aadfe6c24900688fa7dfb9760451cdfa5f9d1fcc.zip
cluster: close ownerless handles on disconnect()
When a worker is disconnecting, it shuts down all of the handles it is waiting on. It is possible that a handle does not have an owner, which causes a crash. This commit closes such handles without accessing the missing owner. Fixes: https://github.com/nodejs/node/issues/6561 PR-URL: https://github.com/nodejs/node/pull/6909 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Diffstat (limited to 'lib/cluster.js')
-rw-r--r--lib/cluster.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/cluster.js b/lib/cluster.js
index d60366aaf1..175645f713 100644
--- a/lib/cluster.js
+++ b/lib/cluster.js
@@ -719,7 +719,11 @@ function workerInit() {
const handle = handles[key];
delete handles[key];
waitingCount++;
- handle.owner.close(checkWaitingCount);
+
+ if (handle.owner)
+ handle.owner.close(checkWaitingCount);
+ else
+ handle.close(checkWaitingCount);
}
checkWaitingCount();