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: nodejs#6561
PR-URL: nodejs#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 Fishrock123 committed May 30, 2016
1 parent fd86b3f commit a40585f
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 a40585f

Please sign in to comment.