Skip to content

Commit

Permalink
dgram: make process.binding('udp_wrap') internal
Browse files Browse the repository at this point in the history
PR-URL: #22475
Refs: #22160
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
cjihrig committed Aug 31, 2018
1 parent 98b5d66 commit c8950cd
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 14 deletions.
3 changes: 2 additions & 1 deletion lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ const {
defaultTriggerAsyncIdScope,
symbols: { async_id_symbol, owner_symbol }
} = require('internal/async_hooks');
const { internalBinding } = require('internal/bootstrap/loaders');
const { UV_UDP_REUSEADDR } = process.binding('constants').os;

const { UDP, SendWrap } = process.binding('udp_wrap');
const { UDP, SendWrap } = internalBinding('udp_wrap');

const BIND_STATE_UNBOUND = 0;
const BIND_STATE_BINDING = 1;
Expand Down
1 change: 1 addition & 0 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
new SafeSet([
'cares_wrap',
'fs_event_wrap',
'udp_wrap',
'uv',
'pipe_wrap',
'http_parser',
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const { WriteWrap } = internalBinding('stream_wrap');
const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
const { TCP } = internalBinding('tcp_wrap');
const { TTY } = internalBinding('tty_wrap');
const { UDP } = process.binding('udp_wrap');
const { UDP } = internalBinding('udp_wrap');
const SocketList = require('internal/socket_list');
const { owner_symbol } = require('internal/async_hooks').symbols;
const { convertToValidSignal } = require('internal/util');
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/dgram.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
const { codes } = require('internal/errors');
const { internalBinding } = require('internal/bootstrap/loaders');
const { UDP } = process.binding('udp_wrap');
const { UDP } = internalBinding('udp_wrap');
const { isInt32 } = require('internal/validators');
const TTYWrap = internalBinding('tty_wrap');
const { UV_EINVAL } = internalBinding('uv');
Expand Down
2 changes: 1 addition & 1 deletion src/udp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,4 @@ uv_udp_t* UDPWrap::UVHandle() {

} // namespace node

NODE_BUILTIN_MODULE_CONTEXT_AWARE(udp_wrap, node::UDPWrap::Initialize)
NODE_MODULE_CONTEXT_AWARE_INTERNAL(udp_wrap, node::UDPWrap::Initialize)
2 changes: 1 addition & 1 deletion test/parallel/test-accessor-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const assert = require('assert');
// their prototype
const { internalBinding } = require('internal/test/binding');
const TTY = internalBinding('tty_wrap').TTY;
const UDP = process.binding('udp_wrap').UDP;
const UDP = internalBinding('udp_wrap').UDP;

{
// Should throw instead of raise assertions
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-cluster-dgram-bind-fd.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
if (common.isWindows)
Expand All @@ -9,7 +10,6 @@ const PACKETS_PER_WORKER = 10;
const assert = require('assert');
const cluster = require('cluster');
const dgram = require('dgram');
const { UDP } = process.binding('udp_wrap');

if (cluster.isMaster)
master();
Expand All @@ -18,6 +18,9 @@ else


function master() {
const { internalBinding } = require('internal/test/binding');
const { UDP } = internalBinding('udp_wrap');

// Create a handle and use its fd.
const rawHandle = new UDP();
const err = rawHandle.bind(common.localhostIPv4, 0, 0);
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-dgram-bind-fd.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
if (common.isWindows)
common.skip('Does not support binding fd on Windows');

const assert = require('assert');
const dgram = require('dgram');
const { UDP } = process.binding('udp_wrap');
const { internalBinding } = require('internal/test/binding');
const { UDP } = internalBinding('udp_wrap');
const { UV_UDP_REUSEADDR } = process.binding('constants').os;

const BUFFER_SIZE = 4096;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dgram-create-socket-handle-fd.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ if (common.isWindows)

const assert = require('assert');
const dgram = require('dgram');
const { UDP } = process.binding('udp_wrap');
const { internalBinding } = require('internal/test/binding');
const { UDP } = internalBinding('udp_wrap');
const { TCP, constants } = internalBinding('tcp_wrap');
const _createSocketHandle = dgram._createSocketHandle;

Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-dgram-create-socket-handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
const common = require('../common');
const assert = require('assert');
const { _createSocketHandle } = require('internal/dgram');
const UDP = process.binding('udp_wrap').UDP;
const { internalBinding } = require('internal/test/binding');
const UDP = internalBinding('udp_wrap').UDP;

{
// Create a handle that is not bound.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ require('../common');

const assert = require('assert');
const { internalBinding } = require('internal/test/binding');

[
process.binding('udp_wrap').UDP.prototype.bind6,
internalBinding('udp_wrap').UDP.prototype.bind6,
internalBinding('tcp_wrap').TCP.prototype.bind6,
process.binding('udp_wrap').UDP.prototype.send6,
internalBinding('udp_wrap').UDP.prototype.send6,
internalBinding('tcp_wrap').TCP.prototype.bind,
process.binding('udp_wrap').UDP.prototype.close,
internalBinding('udp_wrap').UDP.prototype.close,
internalBinding('tcp_wrap').TCP.prototype.open
].forEach((binding, i) => {
assert.strictEqual('prototype' in binding, false, `Test ${i} failed`);
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-async-wrap-getasyncid.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
}

{
const binding = process.binding('udp_wrap');
const binding = internalBinding('udp_wrap');
const handle = new binding.UDP();
const req = new binding.SendWrap();
testInitialized(handle, 'UDP');
Expand Down

0 comments on commit c8950cd

Please sign in to comment.