Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions lib/internal/cluster/child.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ cluster._getServer = function(obj, options, cb) {
if (typeof obj._setServerData === 'function')
obj._setServerData(reply.data);

if (handle)
shared(reply, handle, indexesKey, index, cb); // Shared listen socket.
else
rr(reply, indexesKey, index, cb); // Round-robin.
if (handle) {
// Shared listen socket
shared(reply, { handle, indexesKey, index }, cb);
} else {
// Round-robin.
rr(reply, { indexesKey, index }, cb);
}
});

obj.once('listening', () => {
Expand All @@ -129,7 +132,7 @@ function removeIndexesKey(indexesKey, index) {
}

// Shared listen socket.
function shared(message, handle, indexesKey, index, cb) {
function shared(message, { handle, indexesKey, index }, cb) {
const key = message.key;
// Monkey-patch the close() method so we can keep track of when it's
// closed. Avoids resource leaks when the handle is short-lived.
Expand All @@ -146,8 +149,8 @@ function shared(message, handle, indexesKey, index, cb) {
cb(message.errno, handle);
}

// Round-robin. Primary distributes handles across workers.
function rr(message, indexesKey, index, cb) {
// Round-robin. Master distributes handles across workers.
function rr(message, { indexesKey, index }, cb) {
if (message.errno)
return cb(message.errno, null);

Expand Down