cluster: remove handles when disconnecting worker
authorBen Noordhuis <info@bnoordhuis.nl>
Tue, 3 Nov 2015 18:06:50 +0000 (19:06 +0100)
committerJames M Snell <jasnell@gmail.com>
Wed, 23 Dec 2015 16:38:33 +0000 (08:38 -0800)
commitd46d9f1dd4ed49d554b7a90f5a3fcd64cd10fe46
tree73ac3695778ea046a4cbcfdf753c218c770e378b
parent02ea6f4123cd5d3be103e09f4b89e5f62dacd2f9
cluster: remove handles when disconnecting worker

Due to the race window between the master's "disconnect" message and the
worker's "handle received" message, connections sometimes got stuck in
the pending handles queue when calling `worker.disconnect()` in the
master process.

The observable effect from the client's perspective was a TCP or HTTP
connection that simply stalled.  This commit fixes that by closing open
handles in the master when the "disconnect" message is sent.

Fixes: https://github.com/nodejs/node/issues/3551
PR-URL: https://github.com/nodejs/node/pull/3677
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
lib/cluster.js
lib/internal/cluster.js [new file with mode: 0644]
node.gyp
test/parallel/test-cluster-disconnect-handles.js [new file with mode: 0644]