From 6a689c8aa3ef3bf517cc86807406b9a8958d4ffb Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 23 Aug 2018 11:36:43 -0400 Subject: [PATCH] lib: make pipe_wrap binding internal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/22482 Refs: https://github.com/nodejs/node/issues/22160 Reviewed-By: Luigi Pinca Reviewed-By: Michaƫl Zasso Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- lib/_tls_wrap.js | 2 +- lib/child_process.js | 3 ++- lib/internal/bootstrap/node.js | 1 + lib/internal/child_process.js | 2 +- lib/net.js | 2 +- src/pipe_wrap.cc | 2 +- test/parallel/test-handle-wrap-isrefed.js | 3 ++- test/parallel/test-net-connect-options-fd.js | 4 +++- test/parallel/test-net-server-listen-handle.js | 2 +- test/parallel/test-process-wrap.js | 2 +- test/sequential/test-async-wrap-getasyncid.js | 4 ++-- 11 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 010973fddc07fd..f806d70b99c76a 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -35,7 +35,7 @@ const debug = util.debuglog('tls'); const { internalBinding } = require('internal/bootstrap/loaders'); const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap'); const tls_wrap = internalBinding('tls_wrap'); -const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap'); +const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); const { owner_symbol } = require('internal/async_hooks').symbols; const { SecureContext: NativeSecureContext } = internalBinding('crypto'); const { diff --git a/lib/child_process.js b/lib/child_process.js index 1ab4150b01e659..05afcdbc6c8bb9 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -28,7 +28,8 @@ const { const { isArrayBufferView } = require('internal/util/types'); const debug = util.debuglog('child_process'); const { Buffer } = require('buffer'); -const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap'); +const { internalBinding } = require('internal/bootstrap/loaders'); +const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); const { ERR_INVALID_ARG_VALUE, ERR_CHILD_PROCESS_IPC_REQUIRED, diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index d65e12cc78d600..26d0b2710f74d6 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -350,6 +350,7 @@ new SafeSet([ 'fs_event_wrap', 'uv', + 'pipe_wrap', 'http_parser', 'process_wrap', 'v8', diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 6c46aaf34dc5aa..70211e99fec954 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -25,7 +25,7 @@ const { internalBinding } = require('internal/bootstrap/loaders'); const { Process } = internalBinding('process_wrap'); const { WriteWrap } = internalBinding('stream_wrap'); -const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap'); +const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); const { TCP } = internalBinding('tcp_wrap'); const { TTY } = internalBinding('tty_wrap'); const { UDP } = process.binding('udp_wrap'); diff --git a/lib/net.js b/lib/net.js index c489353b660a3b..33c41c126ef4c8 100644 --- a/lib/net.js +++ b/lib/net.js @@ -53,7 +53,7 @@ const { Pipe, PipeConnectWrap, constants: PipeConstants -} = process.binding('pipe_wrap'); +} = internalBinding('pipe_wrap'); const { newAsyncId, defaultTriggerAsyncIdScope, diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index a6044b6b267e47..8fcf7007f59df7 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -242,4 +242,4 @@ void PipeWrap::Connect(const FunctionCallbackInfo& args) { } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(pipe_wrap, node::PipeWrap::Initialize) +NODE_MODULE_CONTEXT_AWARE_INTERNAL(pipe_wrap, node::PipeWrap::Initialize) diff --git a/test/parallel/test-handle-wrap-isrefed.js b/test/parallel/test-handle-wrap-isrefed.js index cd0f5a26ca72ad..eb3adf65c13624 100644 --- a/test/parallel/test-handle-wrap-isrefed.js +++ b/test/parallel/test-handle-wrap-isrefed.js @@ -3,6 +3,7 @@ const common = require('../common'); const strictEqual = require('assert').strictEqual; +const { internalBinding } = require('internal/test/binding'); // child_process { @@ -72,7 +73,7 @@ const { kStateSymbol } = require('internal/dgram'); // pipe { - const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap'); + const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); const handle = new Pipe(PipeConstants.SOCKET); strictEqual(Object.getPrototypeOf(handle).hasOwnProperty('hasRef'), true, 'pipe_wrap: hasRef() missing'); diff --git a/test/parallel/test-net-connect-options-fd.js b/test/parallel/test-net-connect-options-fd.js index 76a5e30755b15c..468e230ec7370a 100644 --- a/test/parallel/test-net-connect-options-fd.js +++ b/test/parallel/test-net-connect-options-fd.js @@ -1,3 +1,4 @@ +// Flags: --expose-internals 'use strict'; const common = require('../common'); if (common.isWindows) @@ -6,7 +7,8 @@ if (common.isWindows) const assert = require('assert'); const net = require('net'); const path = require('path'); -const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap'); +const { internalBinding } = require('internal/test/binding'); +const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); diff --git a/test/parallel/test-net-server-listen-handle.js b/test/parallel/test-net-server-listen-handle.js index 32af3c3e0e2dc1..b1182221fcbd06 100644 --- a/test/parallel/test-net-server-listen-handle.js +++ b/test/parallel/test-net-server-listen-handle.js @@ -8,7 +8,7 @@ const fs = require('fs'); const { getSystemErrorName } = require('util'); const { internalBinding } = require('internal/test/binding'); const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap'); -const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap'); +const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); diff --git a/test/parallel/test-process-wrap.js b/test/parallel/test-process-wrap.js index 5c91384453a469..ebbb2af5e93ea1 100644 --- a/test/parallel/test-process-wrap.js +++ b/test/parallel/test-process-wrap.js @@ -25,7 +25,7 @@ require('../common'); const assert = require('assert'); const { internalBinding } = require('internal/test/binding'); const Process = internalBinding('process_wrap').Process; -const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap'); +const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); const pipe = new Pipe(PipeConstants.SOCKET); const p = new Process(); diff --git a/test/sequential/test-async-wrap-getasyncid.js b/test/sequential/test-async-wrap-getasyncid.js index eb4b5aef25507a..6e17b657932ab3 100644 --- a/test/sequential/test-async-wrap-getasyncid.js +++ b/test/sequential/test-async-wrap-getasyncid.js @@ -158,7 +158,7 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check } { - const binding = process.binding('pipe_wrap'); + const binding = internalBinding('pipe_wrap'); const handle = new binding.Pipe(binding.constants.IPC); testInitialized(handle, 'Pipe'); } @@ -169,7 +169,7 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check const server = net.createServer(common.mustCall((socket) => { server.close(); })).listen(common.PIPE, common.mustCall(() => { - const binding = process.binding('pipe_wrap'); + const binding = internalBinding('pipe_wrap'); const handle = new binding.Pipe(binding.constants.SOCKET); testInitialized(handle, 'Pipe'); const req = new binding.PipeConnectWrap();