Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e7ae8eb

Browse filesBrowse files
TrottMylesBorins
authored andcommitted
test: refactor test-child-process-pass-fd
Add a comment explaining the test (especailly why it forks 80 processes. Use destructuring and an arrow function callback. PR-URL: #17596 Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
1 parent 5a9172f commit e7ae8eb
Copy full SHA for e7ae8eb

File tree

Expand file treeCollapse file tree

1 file changed

+12
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-3
lines changed
Open diff view settings
Collapse file

‎test/sequential/test-child-process-pass-fd.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-child-process-pass-fd.js
+12-3Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
'use strict';
22
const common = require('../common');
3+
4+
// On some OS X versions, when passing fd's between processes:
5+
// When the handle associated to a specific file descriptor is closed by the
6+
// sender process before it's received in the destination, the handle is indeed
7+
// closed while it should remain opened. In order to fix this behavior, don't
8+
// close the handle until the `NODE_HANDLE_ACK` is received by the sender.
9+
// This test is basically `test-cluster-net-send` but creating lots of workers
10+
// so the issue reproduces on OS X consistently.
11+
312
if ((process.config.variables.arm_version === '6') ||
413
(process.config.variables.arm_version === '7'))
514
common.skip('Too slow for armv6 and armv7 bots');
615

716
const assert = require('assert');
8-
const fork = require('child_process').fork;
17+
const { fork } = require('child_process');
918
const net = require('net');
1019

1120
const N = 80;
@@ -46,14 +55,14 @@ if (process.argv[2] !== 'child') {
4655
process.on('message', common.mustCall());
4756

4857
const server = net.createServer((c) => {
49-
process.once('message', function(msg) {
58+
process.once('message', (msg) => {
5059
assert.strictEqual(msg, 'got');
5160
c.end('hello');
5261
});
5362
socketConnected();
5463
}).unref();
5564
server.listen(0, common.localhostIPv4, () => {
56-
const port = server.address().port;
65+
const { port } = server.address();
5766
socket = net.connect(port, common.localhostIPv4, socketConnected).unref();
5867
});
5968
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.