cluster: remove handles when disconnecting worker · nodejs/node@d64a56c · GitHub
Skip to content

Commit d64a56c

Browse files
bnoordhuisrvagg
authored andcommitted
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: #3551 PR-URL: #3677 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent b48dbf9 commit d64a56c

4 files changed

Lines changed: 96 additions & 23 deletions

File tree

lib/cluster.js

Lines changed: 26 additions & 23 deletions

lib/internal/cluster.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
'use strict';
2+
3+
// Used in tests.
4+
exports.handles = {};

node.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
'lib/vm.js',
7171
'lib/zlib.js',
7272
'lib/internal/child_process.js',
73+
'lib/internal/cluster.js',
7374
'lib/internal/freelist.js',
7475
'lib/internal/linkedlist.js',
7576
'lib/internal/module.js',
Lines changed: 65 additions & 0 deletions

0 commit comments

Comments
 (0)