Skip to content
Permalink
Browse files

src: move process.binding('uv') to internalBinding

PR-URL: #22163
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
  • Loading branch information...
jasnell committed Aug 6, 2018
1 parent 2fd71f9 commit c7962dcba46f44b888686e6a76bcc6fef2eb7760
@@ -36,6 +36,8 @@ const { HTTPParser } = process.binding('http_parser');
const { freeParser } = require('_http_common');
const { kStateSymbol } = require('internal/dgram');

const { internalBinding } = require('internal/bootstrap/loaders');

const {
UV_EACCES,
UV_EAGAIN,
@@ -45,7 +47,7 @@ const {
UV_ENOENT,
UV_ENOSYS,
UV_ESRCH
} = process.binding('uv');
} = internalBinding('uv');

const { SocketListSend, SocketListReceive } = SocketList;

@@ -3,7 +3,8 @@ const assert = require('assert');
const net = require('net');
const { sendHelper } = require('internal/cluster/utils');
const getOwnPropertyNames = Object.getOwnPropertyNames;
const uv = process.binding('uv');
const { internalBinding } = require('internal/bootstrap/loaders');
const uv = internalBinding('uv');

module.exports = RoundRobinHandle;

@@ -3,7 +3,8 @@ const { codes } = require('internal/errors');
const { UDP } = process.binding('udp_wrap');
const { isInt32 } = require('internal/validators');
const TTYWrap = process.binding('tty_wrap');
const { UV_EINVAL } = process.binding('uv');
const { internalBinding } = require('internal/bootstrap/loaders');
const { UV_EINVAL } = internalBinding('uv');
const { ERR_INVALID_ARG_TYPE, ERR_SOCKET_BAD_TYPE } = codes;
const kStateSymbol = Symbol('state symbol');
let dns; // Lazy load for startup performance.
@@ -15,11 +15,12 @@ const kInfo = Symbol('info');
const messages = new Map();
const codes = {};

const { internalBinding } = require('internal/bootstrap/loaders');
const {
errmap,
UV_EAI_NODATA,
UV_EAI_NONAME
} = process.binding('uv');
} = internalBinding('uv');
const { kMaxLength } = process.binding('buffer');
const { defineProperty } = Object;

@@ -114,7 +114,7 @@ const { isArrayBufferView } = require('internal/util/types');
const { FileHandle } = process.binding('fs');
const binding = process.binding('http2');
const { ShutdownWrap } = process.binding('stream_wrap');
const { UV_EOF } = process.binding('uv');
const { UV_EOF } = internalBinding('uv');

const { StreamPipe } = internalBinding('stream_pipe');
const { _connectionListener: httpConnectionListener } = http;
@@ -13,7 +13,9 @@ const {
arrow_message_private_symbol: kArrowMessagePrivateSymbolIndex,
decorated_private_symbol: kDecoratedPrivateSymbolIndex
} = process.binding('util');
const { errmap } = process.binding('uv');

const { internalBinding } = require('internal/bootstrap/loaders');
const { errmap } = internalBinding('uv');

const noCrypto = !process.versions.openssl;

@@ -4,7 +4,8 @@ const assert = require('assert');
const util = require('util');
const { Socket } = require('net');
const { JSStream } = process.binding('js_stream');
const uv = process.binding('uv');
const { internalBinding } = require('internal/bootstrap/loaders');
const uv = internalBinding('uv');
const debug = util.debuglog('stream_wrap');
const { owner_symbol } = require('internal/async_hooks').symbols;
const { ERR_STREAM_WRAP } = require('internal/errors').codes;
@@ -34,11 +34,12 @@ const {
makeSyncWrite
} = require('internal/net');
const assert = require('assert');
const { internalBinding } = require('internal/bootstrap/loaders');
const {
UV_EADDRINUSE,
UV_EINVAL,
UV_EOF
} = process.binding('uv');
} = internalBinding('uv');

const { Buffer } = require('buffer');
const TTYWrap = process.binding('tty_wrap');
@@ -82,4 +82,4 @@ void Initialize(Local<Object> target,
} // anonymous namespace
} // namespace node

NODE_BUILTIN_MODULE_CONTEXT_AWARE(uv, node::Initialize)
NODE_MODULE_CONTEXT_AWARE_INTERNAL(uv, node::Initialize)
@@ -1,9 +1,11 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const dgram = require('dgram');
const { UV_UNKNOWN } = process.binding('uv');
const { internalBinding } = require('internal/test/binding');
const { UV_UNKNOWN } = internalBinding('uv');

if (cluster.isMaster) {
cluster.fork();
@@ -3,6 +3,8 @@
const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');
const { internalBinding } = require('internal/test/binding');
const { UV_UNKNOWN } = internalBinding('uv');
const { kStateSymbol } = require('internal/dgram');
const mockError = new Error('mock DNS error');

@@ -45,7 +47,6 @@ getSocket((socket) => {

socket.bind(common.mustCall(() => {
const port = socket.address().port;
const errCode = process.binding('uv').UV_UNKNOWN;
const callback = common.mustCall((err) => {
socket.close();
assert.strictEqual(err.code, 'UNKNOWN');
@@ -60,7 +61,7 @@ getSocket((socket) => {
});

socket[kStateSymbol].handle.send = function() {
return errCode;
return UV_UNKNOWN;
};

socket.send('foo', port, common.localhostIPv4, callback);
@@ -1,17 +1,22 @@
'use strict';
// Flags: --expose-internals
'use strict';

const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');
const { SystemError } = require('internal/errors');
const uv = process.binding('uv');
const { internalBinding } = require('internal/test/binding');
const {
UV_EBADF,
UV_EINVAL,
UV_ENOTSOCK
} = internalBinding('uv');

function getExpectedError(type) {
const code = common.isWindows ? 'ENOTSOCK' : 'EBADF';
const message = common.isWindows ?
'socket operation on non-socket' : 'bad file descriptor';
const errno = common.isWindows ? uv.UV_ENOTSOCK : uv.UV_EBADF;
const errno = common.isWindows ? UV_ENOTSOCK : UV_EBADF;
const syscall = `uv_${type}_buffer_size`;
const suffix = common.isWindows ?
'ENOTSOCK (socket operation on non-socket)' : 'EBADF (bad file descriptor)';
@@ -105,7 +110,7 @@ function getExpectedError(type) {
const info = {
code: 'EINVAL',
message: 'invalid argument',
errno: uv.UV_EINVAL,
errno: UV_EINVAL,
syscall: 'uv_recv_buffer_size'
};
const errorObj = {
@@ -128,7 +133,7 @@ function getExpectedError(type) {
const info = {
code: 'EINVAL',
message: 'invalid argument',
errno: uv.UV_EINVAL,
errno: UV_EINVAL,
syscall: 'uv_send_buffer_size'
};
const errorObj = {
@@ -1,12 +1,15 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
const assert = require('assert');
const cares = process.binding('cares_wrap');
const dns = require('dns');
const dnsPromises = dns.promises;

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

// Stub `getaddrinfo` to *always* error.
cares.getaddrinfo = () => process.binding('uv').UV_ENOENT;
cares.getaddrinfo = () => internalBinding('uv').UV_ENOENT;

{
const err = {
@@ -8,8 +8,9 @@ require('../common');

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

const { UV_EAI_MEMORY } = process.binding('uv');
const { UV_EAI_MEMORY } = internalBinding('uv');
const memoryError = errors.dnsException(UV_EAI_MEMORY, 'fhqwhgads');

assert.strictEqual(memoryError.code, 'EAI_MEMORY');
@@ -1,3 +1,4 @@
// Flags: --expose-internals
'use strict';

// This tests that fs.access and fs.accessSync works as expected
@@ -8,7 +9,8 @@ const assert = require('assert');
const fs = require('fs');
const path = require('path');

const uv = process.binding('uv');
const { internalBinding } = require('internal/test/binding');
const { UV_ENOENT } = internalBinding('uv');

const tmpdir = require('../common/tmpdir');
const doesNotExist = path.join(tmpdir.path, '__this_should_not_exist');
@@ -161,7 +163,7 @@ assert.throws(
);
assert.strictEqual(err.constructor, Error);
assert.strictEqual(err.syscall, 'access');
assert.strictEqual(err.errno, uv.UV_ENOENT);
assert.strictEqual(err.errno, UV_ENOENT);
return true;
}
);
@@ -177,7 +179,7 @@ assert.throws(
);
assert.strictEqual(err.constructor, Error);
assert.strictEqual(err.syscall, 'access');
assert.strictEqual(err.errno, uv.UV_ENOENT);
assert.strictEqual(err.errno, UV_ENOENT);
return true;
}
);
@@ -1,10 +1,15 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
const fs = require('fs');
const uv = process.binding('uv');
const { internalBinding } = require('internal/test/binding');
const {
UV_ENOENT,
UV_EEXIST
} = internalBinding('uv');
const path = require('path');
const src = fixtures.path('a.js');
const dest = path.join(tmpdir.path, 'copyfile.out');
@@ -81,14 +86,14 @@ fs.copyFile(src, dest, common.mustCall((err) => {
assert.strictEqual(err.message,
'ENOENT: no such file or directory, copyfile ' +
`'${src}' -> '${dest}'`);
assert.strictEqual(err.errno, uv.UV_ENOENT);
assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'copyfile');
} else {
assert.strictEqual(err.message,
'EEXIST: file already exists, copyfile ' +
`'${src}' -> '${dest}'`);
assert.strictEqual(err.errno, uv.UV_EEXIST);
assert.strictEqual(err.errno, UV_EEXIST);
assert.strictEqual(err.code, 'EEXIST');
assert.strictEqual(err.syscall, 'copyfile');
}
Oops, something went wrong.

0 comments on commit c7962dc

Please sign in to comment.
You can’t perform that action at this time.