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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
  • Loading branch information
cjihrig committed May 24, 2016
1 parent dd21bd9 commit aadfe6c
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 aadfe6c

Please sign in to comment.