mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
cluster, net: fix listen pipe with readable and writable in cluster
PR-URL: https://github.com/nodejs/node/pull/43634 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
5a74939770
commit
c8706f3a7f
3 files changed
+50
-7
No files matched your search
@@ -15,7 +15,7 @@ const { constants } = internalBinding('tcp_wrap');
|
||||
|
||||
module.exports = RoundRobinHandle;
|
||||
|
||||
function RoundRobinHandle(key, address, { port, fd, flags, backlog }) {
|
||||
function RoundRobinHandle(key, address, { port, fd, flags, backlog, readableAll, writableAll }) {
|
||||
this.key = key;
|
||||
this.all = new SafeMap();
|
||||
this.free = new SafeMap();
|
||||
@@ -34,8 +34,12 @@ function RoundRobinHandle(key, address, { port, fd, flags, backlog }) {
|
||||
backlog,
|
||||
});
|
||||
} else
|
||||
this.server.listen(address, backlog); // UNIX socket path.
|
||||
|
||||
this.server.listen({
|
||||
path: address,
|
||||
backlog,
|
||||
readableAll,
|
||||
writableAll,
|
||||
}); // UNIX socket path.
|
||||
this.server.once('listening', () => {
|
||||
this.handle = this.server._handle;
|
||||
this.handle.onconnection = (err, handle) => this.distribute(err, handle);
|
||||
|
||||
+14
-4
@@ -1467,7 +1467,7 @@ function emitListeningNT(self) {
|
||||
|
||||
|
||||
function listenInCluster(server, address, port, addressType,
|
||||
backlog, fd, exclusive, flags) {
|
||||
backlog, fd, exclusive, flags, options) {
|
||||
exclusive = !!exclusive;
|
||||
|
||||
if (cluster === undefined) cluster = require('cluster');
|
||||
@@ -1487,8 +1487,8 @@ function listenInCluster(server, address, port, addressType,
|
||||
fd: fd,
|
||||
flags,
|
||||
backlog,
|
||||
...options,
|
||||
};
|
||||
|
||||
// Get the primary's server handle, and listen on it
|
||||
cluster._getServer(server, serverQuery, listenOnPrimaryHandle);
|
||||
|
||||
@@ -1575,8 +1575,18 @@ Server.prototype.listen = function(...args) {
|
||||
if (options.path && isPipeName(options.path)) {
|
||||
const pipeName = this._pipeName = options.path;
|
||||
backlog = options.backlog || backlogFromArgs;
|
||||
listenInCluster(this, pipeName, -1, -1,
|
||||
backlog, undefined, options.exclusive);
|
||||
listenInCluster(this,
|
||||
pipeName,
|
||||
-1,
|
||||
-1,
|
||||
backlog,
|
||||
undefined,
|
||||
options.exclusive,
|
||||
undefined,
|
||||
{
|
||||
readableAll: options.readableAll,
|
||||
writableAll: options.writableAll,
|
||||
});
|
||||
|
||||
if (!this._handle) {
|
||||
// Failed and an error shall be emitted in the next tick.
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
|
||||
if (common.isWindows) {
|
||||
common.skip('skip on Windows');
|
||||
return;
|
||||
}
|
||||
|
||||
const assert = require('assert');
|
||||
const cluster = require('cluster');
|
||||
const net = require('net');
|
||||
const fs = require('fs');
|
||||
|
||||
if (cluster.isPrimary) {
|
||||
cluster.fork();
|
||||
} else {
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
tmpdir.refresh();
|
||||
const server = net.createServer().listen({
|
||||
path: common.PIPE,
|
||||
readableAll: true,
|
||||
writableAll: true,
|
||||
}, common.mustCall(() => {
|
||||
const stat = fs.statSync(common.PIPE);
|
||||
assert.strictEqual(stat.mode & 0o777, 0o777);
|
||||
server.close();
|
||||
process.disconnect();
|
||||
}));
|
||||
}
|
||||
Reference in new issue
Block a user