| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2002,7 +2002,7 @@ Server.prototype.listen = function(...args) { | |||
| 2002 | 2002 | if (options instanceof TCP) { | |
| 2003 | 2003 | this._handle = options; | |
| 2004 | 2004 | this[async_id_symbol] = this._handle.getAsyncId(); | |
| 2005 | - listenInCluster(this, null, -1, -1, backlogFromArgs); | ||
| 2005 | + listenInCluster(this, null, -1, -1, backlogFromArgs, undefined, true); | ||
| 2006 | 2006 | return this; | |
| 2007 | 2007 | } | |
| 2008 | 2008 | addServerAbortSignalOption(this, options); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,27 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const net = require('net'); | ||
| 5 | + const cluster = require('cluster'); | ||
| 6 | + | ||
| 7 | + // Test if the worker can listen with handle successfully | ||
| 8 | + if (cluster.isPrimary) { | ||
| 9 | + const worker = cluster.fork(); | ||
| 10 | + const server = net.createServer(); | ||
| 11 | + worker.on('online', common.mustCall(() => { | ||
| 12 | + server.listen(common.mustCall(() => { | ||
| 13 | + // Send the server to worker | ||
| 14 | + worker.send(null, server); | ||
| 15 | + })); | ||
| 16 | + })); | ||
| 17 | + worker.on('exit', common.mustCall(() => { | ||
| 18 | + server.close(); | ||
| 19 | + })); | ||
| 20 | + } else { | ||
| 21 | + // The `got` function of net.Server will create a TCP server by listen(handle) | ||
| 22 | + // See lib/internal/child_process.js | ||
| 23 | + process.on('message', common.mustCall((_, server) => { | ||
| 24 | + assert.strictEqual(server instanceof net.Server, true); | ||
| 25 | + process.exit(0); | ||
| 26 | + })); | ||
| 27 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,21 @@ | |||
| 1 | + // Flags: --expose-internals | ||
| 2 | + 'use strict'; | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const net = require('net'); | ||
| 6 | + const cluster = require('cluster'); | ||
| 7 | + const { internalBinding } = require('internal/test/binding'); | ||
| 8 | + const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap'); | ||
| 9 | + | ||
| 10 | + // Test if the worker can listen with handle successfully | ||
| 11 | + if (cluster.isPrimary) { | ||
| 12 | + cluster.fork(); | ||
| 13 | + } else { | ||
| 14 | + const handle = new TCP(TCPConstants.SOCKET); | ||
| 15 | + const errno = handle.bind('0.0.0.0', 0); | ||
| 16 | + assert.strictEqual(errno, 0); | ||
| 17 | + // Execute _listen2 instead of cluster._getServer in listenInCluster | ||
| 18 | + net.createServer().listen(handle, common.mustCall(() => { | ||
| 19 | + process.exit(0); | ||
| 20 | + })); | ||
| 21 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments