const debug = util.debuglog('tls');
const Timer = process.binding('timer_wrap').Timer;
const tls_wrap = process.binding('tls_wrap');
-
-// constructor for lazy loading
-function createTCP() {
- var TCP = process.binding('tcp_wrap').TCP;
- return new TCP();
-}
-
-// constructor for lazy loading
-function createPipe() {
- var Pipe = process.binding('pipe_wrap').Pipe;
- return new Pipe();
-}
+const TCP = process.binding('tcp_wrap').TCP;
+const Pipe = process.binding('pipe_wrap').Pipe;
function onhandshakestart() {
debug('onhandshakestart');
var options = this._tlsOptions;
if (!handle) {
- handle = options.pipe ? createPipe() : createTCP();
+ handle = options.pipe ? new Pipe() : new TCP();
handle.owner = this;
}
const assert = require('assert');
const util = require('util');
const debug = util.debuglog('child_process');
+const constants = require('constants');
const Process = process.binding('process_wrap').Process;
const WriteWrap = process.binding('stream_wrap').WriteWrap;
const uv = process.binding('uv');
-
-var spawn_sync; // Lazy-loaded process.binding('spawn_sync')
-var constants; // Lazy-loaded process.binding('constants')
+const spawn_sync = process.binding('spawn_sync');
+const Pipe = process.binding('pipe_wrap').Pipe;
+const TTY = process.binding('tty_wrap').TTY;
+const TCP = process.binding('tcp_wrap').TCP;
+const UDP = process.binding('udp_wrap').UDP;
const errnoException = util._errnoException;
-var handleWraps = {};
-
-function handleWrapGetter(name, callback) {
- var cons;
-
- Object.defineProperty(handleWraps, name, {
- get: function() {
- if (cons !== undefined) return cons;
- return cons = callback();
- }
- });
-}
-
-handleWrapGetter('Pipe', function() {
- return process.binding('pipe_wrap').Pipe;
-});
-
-handleWrapGetter('TTY', function() {
- return process.binding('tty_wrap').TTY;
-});
-
-handleWrapGetter('TCP', function() {
- return process.binding('tcp_wrap').TCP;
-});
-
-handleWrapGetter('UDP', function() {
- return process.binding('udp_wrap').UDP;
-});
-
-// constructors for lazy loading
-function createPipe(ipc) {
- return new handleWraps.Pipe(ipc);
-}
function createSocket(pipe, readable) {
var s = new net.Socket({ handle: pipe });
message.type = 'net.Socket';
} else if (handle instanceof net.Server) {
message.type = 'net.Server';
- } else if (handle instanceof process.binding('tcp_wrap').TCP ||
- handle instanceof process.binding('pipe_wrap').Pipe) {
+ } else if (handle instanceof TCP || handle instanceof Pipe) {
message.type = 'net.Native';
} else if (handle instanceof dgram.Socket) {
message.type = 'dgram.Socket';
- } else if (handle instanceof process.binding('udp_wrap').UDP) {
+ } else if (handle instanceof UDP) {
message.type = 'dgram.Native';
} else {
throw new TypeError("This handle type can't be sent");
exports._forkChild = function(fd) {
// set process.send()
- var p = createPipe(true);
+ var p = new Pipe(true);
p.open(fd);
p.unref();
setupChannel(process, p);
};
if (!sync)
- a.handle = createPipe();
+ a.handle = new Pipe();
acc.push(a);
} else if (stdio === 'ipc') {
throw new Error('You cannot use IPC with synchronous forks');
}
- ipc = createPipe(true);
+ ipc = new Pipe(true);
ipcFd = i;
acc.push({
function ChildProcess() {
EventEmitter.call(this);
- // Initialize TCPWrap and PipeWrap
- process.binding('tcp_wrap');
- process.binding('pipe_wrap');
-
var self = this;
this._closesNeeded = 1;
function getHandleWrapType(stream) {
- if (stream instanceof handleWraps.Pipe) return 'pipe';
- if (stream instanceof handleWraps.TTY) return 'tty';
- if (stream instanceof handleWraps.TCP) return 'tcp';
- if (stream instanceof handleWraps.UDP) return 'udp';
+ if (stream instanceof Pipe) return 'pipe';
+ if (stream instanceof TTY) return 'tty';
+ if (stream instanceof TCP) return 'tcp';
+ if (stream instanceof UDP) return 'udp';
return false;
}
ChildProcess.prototype.kill = function(sig) {
var signal;
- if (!constants) {
- constants = process.binding('constants');
- }
-
if (sig === 0) {
signal = 0;
} else if (!sig) {
if (typeof signal === 'number')
return signal;
- if (!constants)
- constants = process.binding('constants');
-
if (!(signal in constants))
throw new Error('Unknown signal: ' + signal);
}
}
- if (!spawn_sync)
- spawn_sync = process.binding('spawn_sync');
-
var result = spawn_sync.spawn(options);
if (result.output && options.encoding) {
const SCHED_NONE = 1;
const SCHED_RR = 2;
+const uv = process.binding('uv');
+
const cluster = new EventEmitter;
module.exports = cluster;
cluster.Worker = Worker;
// Hack: translate 'EADDRINUSE' error string back to numeric error code.
// It works but ideally we'd have some backchannel between the net and
// cluster modules for stuff like this.
- var errno = process.binding('uv')['UV_' + err.errno];
+ var errno = uv['UV_' + err.errno];
send(errno, null);
});
};
if (typeof arguments[arguments.length - 1] === 'function')
self.once('listening', arguments[arguments.length - 1]);
- const UDP = process.binding('udp_wrap').UDP;
if (port instanceof UDP) {
replaceHandle(self, port);
startListening(self);
const pathModule = require('path');
const binding = process.binding('fs');
-const constants = process.binding('constants');
+const constants = require('constants');
const fs = exports;
const Stream = require('stream').Stream;
const EventEmitter = require('events').EventEmitter;
const FSReqWrap = binding.FSReqWrap;
+const FSEvent = process.binding('fs_event_wrap').FSEvent;
const Readable = Stream.Readable;
const Writable = Stream.Writable;
EventEmitter.call(this);
var self = this;
- var FSEvent = process.binding('fs_event_wrap').FSEvent;
this._handle = new FSEvent();
this._handle.owner = this;
const assert = require('assert');
const cares = process.binding('cares_wrap');
const uv = process.binding('uv');
-const Pipe = process.binding('pipe_wrap').Pipe;
+const TTYWrap = process.binding('tty_wrap');
+const TCP = process.binding('tcp_wrap').TCP;
+const Pipe = process.binding('pipe_wrap').Pipe;
const TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
const PipeConnectWrap = process.binding('pipe_wrap').PipeConnectWrap;
const ShutdownWrap = process.binding('stream_wrap').ShutdownWrap;
function noop() {}
-// constructor for lazy loading
-function createPipe() {
- return new Pipe();
-}
-
-// constructor for lazy loading
-function createTCP() {
- var TCP = process.binding('tcp_wrap').TCP;
- return new TCP();
-}
-
-
function createHandle(fd) {
- var tty = process.binding('tty_wrap');
- var type = tty.guessHandleType(fd);
- if (type === 'PIPE') return createPipe();
- if (type === 'TCP') return createTCP();
+ var type = TTYWrap.guessHandleType(fd);
+ if (type === 'PIPE') return new Pipe();
+ if (type === 'TCP') return new TCP();
throw new TypeError('Unsupported fd type: ' + type);
}
debug('pipe', pipe, options.path);
if (!this._handle) {
- this._handle = pipe ? createPipe() : createTCP();
+ this._handle = pipe ? new Pipe() : new TCP();
initSocketHandle(this);
}
handle.writable = true;
assert(!address && !port);
} else if (port === -1 && addressType === -1) {
- handle = createPipe();
+ handle = new Pipe();
if (process.platform === 'win32') {
var instances = parseInt(process.env.NODE_PENDING_PIPE_INSTANCES);
if (!isNaN(instances)) {
}
}
} else {
- handle = createTCP();
+ handle = new TCP();
isTCP = true;
}
// When the ip is omitted it can be the second argument.
var backlog = toNumber(arguments[1]) || toNumber(arguments[2]);
- const TCP = process.binding('tcp_wrap').TCP;
-
if (arguments.length === 0 || typeof arguments[0] === 'function') {
// Bind to a random port.
listen(self, null, 0, null, backlog);
const net = require('net');
const url = require('url');
const util = require('util');
+const binding = process.binding('crypto');
// Allow {CLIENT_RENEG_LIMIT} client-initiated session renegotiations
// every {CLIENT_RENEG_WINDOW} seconds. An error event is emitted if more
exports.DEFAULT_ECDH_CURVE = 'prime256v1';
exports.getCiphers = function() {
- const names = process.binding('crypto').getSSLCiphers();
+ const names = binding.getSSLCiphers();
// Drop all-caps names in favor of their lowercase aliases,
var ctx = {};
names.forEach(function(name) {
'use strict';
+const uv = process.binding('uv');
+
const formatRegExp = /%[sdj%]/g;
exports.format = function(f) {
if (typeof f !== 'string') {
}, 'util.pump(): Use readableStream.pipe() instead');
-var uv;
exports._errnoException = function(err, syscall, original) {
- if (uv === undefined) uv = process.binding('uv');
var errname = uv.errname(err);
var message = syscall + ' ' + errname;
if (original)