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 Myles Borins committed Jul 12, 2016
1 parent c0a42bc commit f152adf
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 @@ -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();
Expand Down

0 comments on commit f152adf

Please sign in to comment.