diff options
author | Rich Trott <rtrott@gmail.com> | 2017-12-11 02:55:00 +0300 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2017-12-12 11:28:45 +0300 |
commit | e7ae8eb457ae764565bd3cee6d36bfe7919601c7 (patch) | |
tree | 373d4ca81ce09e56ca8a2f75df344188d3ac3372 | |
parent | 5a9172fe06f5034f3e2d1508fe16744c79b92af2 (diff) |
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: https://github.com/nodejs/node/pull/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>
-rw-r--r-- | test/sequential/test-child-process-pass-fd.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/test/sequential/test-child-process-pass-fd.js b/test/sequential/test-child-process-pass-fd.js index 8cc11f6c11f..73e469cdede 100644 --- a/test/sequential/test-child-process-pass-fd.js +++ b/test/sequential/test-child-process-pass-fd.js @@ -1,11 +1,20 @@ 'use strict'; const common = require('../common'); + +// On some OS X versions, when passing fd's between processes: +// When the handle associated to a specific file descriptor is closed by the +// sender process before it's received in the destination, the handle is indeed +// closed while it should remain opened. In order to fix this behavior, don't +// close the handle until the `NODE_HANDLE_ACK` is received by the sender. +// This test is basically `test-cluster-net-send` but creating lots of workers +// so the issue reproduces on OS X consistently. + if ((process.config.variables.arm_version === '6') || (process.config.variables.arm_version === '7')) common.skip('Too slow for armv6 and armv7 bots'); const assert = require('assert'); -const fork = require('child_process').fork; +const { fork } = require('child_process'); const net = require('net'); const N = 80; @@ -46,14 +55,14 @@ if (process.argv[2] !== 'child') { process.on('message', common.mustCall()); const server = net.createServer((c) => { - process.once('message', function(msg) { + process.once('message', (msg) => { assert.strictEqual(msg, 'got'); c.end('hello'); }); socketConnected(); }).unref(); server.listen(0, common.localhostIPv4, () => { - const port = server.address().port; + const { port } = server.address(); socket = net.connect(port, common.localhostIPv4, socketConnected).unref(); }); } |