Skip to content

Commit

Permalink
cluster: close ownerless handles on disconnect()
Browse files Browse the repository at this point in the history
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: #6561
PR-URL: #6909
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
  • Loading branch information
cjihrig authored and rvagg committed Jun 2, 2016
1 parent 4cc6a18 commit 28b7342
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 28b7342

Please sign in to comment.