Remove the errno global. It's a property on the process object now.
Fixes #3095.
var writeReq = channel.writeUtf8String(string, handle);
if (!writeReq) {
- var er = errnoException(errno, 'write', 'cannot write to IPC channel.');
+ var er = errnoException(process._errno,
+ 'write',
+ 'cannot write to IPC channel.');
this.emit('error', er);
}
//
// - spawn failures are reported with exitCode == -1
//
- var err = (exitCode == -1) ? errnoException(errno, 'spawn') : null;
+ var err = (exitCode == -1) ? errnoException(process._errno, 'spawn') : null;
if (signalCode) {
self.signalCode = signalCode;
this._handle.close();
this._handle = null;
- throw errnoException(errno, 'spawn');
+ throw errnoException(process._errno, 'spawn');
}
this.pid = this._handle.pid;
/* Success. */
this.killed = true;
return true;
- } else if (errno == 'ESRCH') {
+ } else if (process._errno == 'ESRCH') {
/* Already dead. */
- } else if (errno == 'EINVAL' || errno == 'ENOSYS') {
+ } else if (process._errno == 'EINVAL' || process._errno == 'ENOSYS') {
/* The underlying platform doesn't support this signal. */
- throw errnoException(errno, 'kill');
+ throw errnoException(process._errno, 'kill');
} else {
/* Other error, almost certainly EPERM. */
- this.emit('error', errnoException(errno, 'kill'));
+ this.emit('error', errnoException(process._errno, 'kill'));
}
}
return; // handle has been closed in the mean time
if (self._handle.bind(ip, port || 0, /*flags=*/ 0)) {
- self.emit('error', errnoException(errno, 'bind'));
+ self.emit('error', errnoException(process._errno, 'bind'));
self._bindState = BIND_STATE_UNBOUND;
// Todo: close?
return;
}
else {
// don't emit as error, dgram_legacy.js compatibility
- var err = errnoException(errno, 'send');
+ var err = errnoException(process._errno, 'send');
process.nextTick(function() {
callback(err);
});
var address = this._handle.getsockname();
if (!address)
- throw errnoException(errno, 'getsockname');
+ throw errnoException(process._errno, 'getsockname');
return address;
};
Socket.prototype.setBroadcast = function(arg) {
if (this._handle.setBroadcast((arg) ? 1 : 0)) {
- throw errnoException(errno, 'setBroadcast');
+ throw errnoException(process._errno, 'setBroadcast');
}
};
}
if (this._handle.setTTL(arg)) {
- throw errnoException(errno, 'setTTL');
+ throw errnoException(process._errno, 'setTTL');
}
return arg;
}
if (this._handle.setMulticastTTL(arg)) {
- throw errnoException(errno, 'setMulticastTTL');
+ throw errnoException(process._errno, 'setMulticastTTL');
}
return arg;
arg = arg ? 1 : 0;
if (this._handle.setMulticastLoopback(arg)) {
- throw errnoException(errno, 'setMulticastLoopback');
+ throw errnoException(process._errno, 'setMulticastLoopback');
}
return arg; // 0.4 compatibility
}
if (this._handle.addMembership(multicastAddress, interfaceAddress)) {
- throw new errnoException(errno, 'addMembership');
+ throw new errnoException(process._errno, 'addMembership');
}
};
}
if (this._handle.dropMembership(multicastAddress, interfaceAddress)) {
- throw new errnoException(errno, 'dropMembership');
+ throw new errnoException(process._errno, 'dropMembership');
}
};
function onMessage(handle, slab, start, len, rinfo) {
var self = handle.owner;
- if (!slab) return self.emit('error', errnoException(errno, 'recvmsg'));
+ if (!slab) {
+ return self.emit('error', errnoException(process._errno, 'recvmsg'));
+ }
rinfo.size = len; // compatibility
self.emit('message', slab.slice(start, start + len), rinfo);
}
callback(null, addresses[0], addresses[0].indexOf(':') >= 0 ? 6 : 4);
}
} else {
- callback(errnoException(errno, 'getaddrinfo'));
+ callback(errnoException(process._errno, 'getaddrinfo'));
}
}
var wrap = cares.getaddrinfo(domain, family);
if (!wrap) {
- throw errnoException(errno, 'getaddrinfo');
+ throw errnoException(process._errno, 'getaddrinfo');
}
wrap.oncomplete = onanswer;
if (!status) {
callback(null, result);
} else {
- callback(errnoException(errno, bindingName));
+ callback(errnoException(process._errno, bindingName));
}
}
callback = makeAsync(callback);
var wrap = binding(name, onanswer);
if (!wrap) {
- throw errnoException(errno, bindingName);
+ throw errnoException(process._errno, bindingName);
}
callback.immediately = true;
this._handle.onchange = function(status, event, filename) {
if (status) {
self._handle.close();
- self.emit('error', errnoException(errno, 'watch'));
+ self.emit('error', errnoException(process._errno, 'watch'));
} else {
self.emit('change', event, filename);
}
if (r) {
this._handle.close();
- throw errnoException(errno, 'watch');
+ throw errnoException(process._errno, 'watch');
}
};
var shutdownReq = this._handle.shutdown();
if (!shutdownReq)
- return this._destroy(errnoException(errno, 'shutdown'));
+ return this._destroy(errnoException(process._errno, 'shutdown'));
shutdownReq.oncomplete = afterShutdown;
}
this._handle.reading = true;
var r = this._handle.readStart();
if (r)
- this._destroy(errnoException(errno, 'read'));
+ this._destroy(errnoException(process._errno, 'read'));
} else {
debug('readStart already has been called.');
}
timers.active(self);
var end = offset + length;
- debug('onread', global.errno, offset, length, end);
+ debug('onread', process._errno, offset, length, end);
if (buffer) {
debug('got data');
debug('readStop');
var r = handle.readStop();
if (r)
- self._destroy(errnoException(errno, 'read'));
+ self._destroy(errnoException(process._errno, 'read'));
}
- } else if (errno == 'EOF') {
+ } else if (process._errno == 'EOF') {
debug('EOF');
if (self._readableState.length === 0)
// procedure. No need to wait for all the data to be consumed.
self.emit('_socketEnd');
} else {
- debug('error', errno);
+ debug('error', process._errno);
// Error
- self._destroy(errnoException(errno, 'read'));
+ self._destroy(errnoException(process._errno, 'read'));
}
}
var writeReq = createWriteReq(this._handle, data, enc);
if (!writeReq || typeof writeReq !== 'object')
- return this._destroy(errnoException(errno, 'write'), cb);
+ return this._destroy(errnoException(process._errno, 'write'), cb);
writeReq.oncomplete = afterWrite;
this._bytesDispatched += writeReq.bytes;
}
if (status) {
- debug('write failure', errnoException(errno, 'write'));
- self._destroy(errnoException(errno, 'write'), req.cb);
+ debug('write failure', errnoException(process._errno, 'write'));
+ self._destroy(errnoException(process._errno, 'write'), req.cb);
return;
}
}
if (r) {
- self._destroy(errnoException(errno, 'bind'));
+ self._destroy(errnoException(process._errno, 'bind'));
return;
}
}
if (connectReq !== null) {
connectReq.oncomplete = afterConnect;
} else {
- self._destroy(errnoException(errno, 'connect'));
+ self._destroy(errnoException(process._errno, 'connect'));
}
}
} else {
self._connecting = false;
- self._destroy(errnoException(errno, 'connect'));
+ self._destroy(errnoException(process._errno, 'connect'));
}
}
default:
// Not a fd we can listen on. This will trigger an error.
debug('listen invalid fd=' + fd + ' type=' + type);
- global.errno = 'EINVAL'; // hack, callers expect that errno is set
+ process._errno = 'EINVAL'; // hack, callers expect that errno is set
handle = null;
break;
}
debug('_listen2: create a handle');
self._handle = createServerHandle(address, port, addressType, fd);
if (!self._handle) {
- var error = errnoException(errno, 'listen');
+ var error = errnoException(process._errno, 'listen');
process.nextTick(function() {
self.emit('error', error);
});
r = self._handle.listen(backlog || 511);
if (r) {
- var ex = errnoException(errno, 'listen');
+ var ex = errnoException(process._errno, 'listen');
self._handle.close();
self._handle = null;
process.nextTick(function() {
debug('onconnection');
if (!clientHandle) {
- self.emit('error', errnoException(errno, 'accept'));
+ self.emit('error', errnoException(process._errno, 'accept'));
return;
}
var oldRows = this.rows;
var winSize = this._handle.getWindowSize();
if (!winSize) {
- this.emit('error', errnoException(errno, 'getWindowSize'));
+ this.emit('error', errnoException(process._errno, 'getWindowSize'));
return;
}
var newCols = winSize[0];
void SetErrno(uv_err_t err) {
HandleScope scope;
+ static Persistent<String> errno_symbol;
if (errno_symbol.IsEmpty()) {
- errno_symbol = NODE_PSYMBOL("errno");
+ errno_symbol = NODE_PSYMBOL("_errno");
}
if (err.code == UV_UNKNOWN) {
char errno_buf[100];
snprintf(errno_buf, 100, "Unknown system errno %d", err.sys_errno_);
- Context::GetCurrent()->Global()->Set(errno_symbol, String::New(errno_buf));
+ process->Set(errno_symbol, String::New(errno_buf));
} else {
- Context::GetCurrent()->Global()->Set(errno_symbol,
- String::NewSymbol(uv_err_name(err)));
+ process->Set(errno_symbol, String::NewSymbol(uv_err_name(err)));
}
}
}
if (r) {
- throw errnoException(errno, 'kill');
+ throw errnoException(process._errno, 'kill');
}
return true;
var r = wrap.start(signum);
if (r) {
wrap.close();
- throw errnoException(errno, 'uv_signal_start');
+ throw errnoException(process._errno, 'uv_signal_start');
}
signalWraps[type] = wrap;
process,
global];
- if (global.errno) {
- knownGlobals.push(errno);
- }
-
if (global.gc) {
knownGlobals.push(gc);
}
child.on('exit', function() {
child._handle = {
kill: function() {
- global.errno = 42;
+ process._errno = 42;
return -1;
}
};
// Should not be able to bind to the same port again
var r = handle.bind('0.0.0.0', common.PORT);
assert.equal(-1, r);
-console.log(errno);
-assert.equal(errno, 'EINVAL');
+console.log(process._errno);
+assert.equal(process._errno, 'EINVAL');
handle.close();