From 8aba4119f70e9d2b1f61f72fe2bf959adbb279a7 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 23 May 2016 10:55:48 -0400 Subject: [PATCH] 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 Reviewed-By: James M Snell Reviewed-By: Santiago Gimeno --- lib/cluster.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/cluster.js b/lib/cluster.js index e4bbd5f3ff7838..62eb78eeba113e 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -703,7 +703,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();